P9690 [GDCPC2023] Programming Contest 题解
upd on 2023/10/5 9:54 将思路中提到的 ans-- 改为 LATEX 公式。
好水啊
先计算出如果没有停办的答案,即
#include <bits/stdc++.h>
using namespace std;
#define int long long // DILL 是个好习惯,不过容易爆空间
const int N = 1e2 + 5; // 定义常量是个好习惯
int t, y1, y2, n, a[N];
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>t;
while(t--) {
cin>>y1>>n;
for(int i = 1; i <= n; i++) cin>>a[i];
cin>>y2;
int ans = y2 - y1 + 1; // 计算初始答案
for(int i = 1; i <= n; i++)
if(a[i] < y2) ans--; // 遍历判断是否在 y2 前停办
cout<<ans<<endl;
}
return 0;
}