提出 #1666463
ソースコード 拡げる
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<x<<endl
#define debug2(x,y) cerr << #x <<": "<< x <<", "<< #y <<": "<< (y) << endl
#define answer(x) cout << x <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << x << endl
using namespace std;
typedef vector<int> VI;
int main() {
int N, M;
cin >> N;
VI D(N);
REP(i, N) { scanf("%d", &D[i]); }
cin >> M;
VI T(M);
REP(i, M) { scanf("%d", &T[i]); }
sort(all(D));
VI used(N, 0);
REP(i, M) {
auto itr = lower_bound(all(D), T[i]);
int j = distance(D.begin(), itr);
if(*itr != T[i]) {
cout << "NO" << endl;
return 0;
}
else if(used[j]) {
while(*(itr++) == T[i] && used[j++]) {}
if(*(--itr) != T[i]) {
cout << "NO" << endl;
return 0;
}
else { used[--j] = 1; }
}
else { used[j] = 1; }
}
cout << "YES" << endl;
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
B - Problem Set |
| ユーザ |
kn1cht |
| 言語 |
C++14 (GCC 5.4.1) |
| 得点 |
200 |
| コード長 |
1266 Byte |
| 結果 |
AC |
| 実行時間 |
1355 ms |
| メモリ |
2560 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, N) { scanf("%d", &D[i]); }
^
./Main.cpp:26:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, M) { scanf("%d", &T[i]); }
^
ジャッジ結果
| セット名 |
sample |
dataset1 |
dataset2 |
| 得点 / 配点 |
0 / 0 |
100 / 100 |
100 / 100 |
| 結果 |
|
|
|
| セット名 |
テストケース |
| sample |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| dataset1 |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
| dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01-01.txt |
AC |
1 ms |
256 KiB |
| 01-02.txt |
AC |
1 ms |
256 KiB |
| 01-03.txt |
AC |
1 ms |
256 KiB |
| 01-04.txt |
AC |
1 ms |
256 KiB |
| 01-05.txt |
AC |
1 ms |
256 KiB |
| 01-06.txt |
AC |
1 ms |
256 KiB |
| 01-07.txt |
AC |
1 ms |
256 KiB |
| 01-08.txt |
AC |
1 ms |
256 KiB |
| 01-09.txt |
AC |
1 ms |
256 KiB |
| 02-01.txt |
AC |
37 ms |
1792 KiB |
| 02-02.txt |
AC |
39 ms |
1792 KiB |
| 02-03.txt |
AC |
84 ms |
2560 KiB |
| 02-04.txt |
AC |
39 ms |
1792 KiB |
| 02-05.txt |
AC |
62 ms |
2560 KiB |
| 02-06.txt |
AC |
29 ms |
1792 KiB |
| 02-07.txt |
AC |
1253 ms |
2560 KiB |
| 02-08.txt |
AC |
1318 ms |
2560 KiB |
| 02-09.txt |
AC |
1313 ms |
2560 KiB |
| 02-10.txt |
AC |
1355 ms |
2560 KiB |
| sample-01.txt |
AC |
1 ms |
256 KiB |
| sample-02.txt |
AC |
1 ms |
256 KiB |
| sample-03.txt |
AC |
1 ms |
256 KiB |
| sample-04.txt |
AC |
1 ms |
256 KiB |