2 条题解
-
-1
#include <cstdio> #include <cctype> #include <algorithm> using namespace std; int m, n, a[1000005], k; inline int read() { int res = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) { res = (res << 3) + (res << 1) + (c - 48); c = getchar(); } return res; } int main() { freopen("ball.in", "r", stdin); freopen("ball.out", "w", stdout); n = read(), m = read(); for (int i = 0; i < n; i++) a[i] = read(); sort(a, a + n); for (; m--; ) { k = read(); if (binary_search(a, a + n, k)) printf("YES\n"); else printf("NO\n"); } return 0; }
-
-3
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("ball.in","r",stdin);
freopen("ball.out","w",stdout);
int m,n;
scanf("%d %d",&m,&n);
int a[100010];
int sum;
for(int i=0;i<m;i++){
scanf("%d",&a[i]);
}
sort(a,a+m);
for(int i=0;i<n;i++){
cin>>sum;
if(binary_search(a,a+m,sum)){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}
- 1
信息
- ID
- 403
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- (无)
- 递交数
- 99
- 已通过
- 42
- 上传者