Submission #68585
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <bits/stdc++.h> using namespace std; #define int int64_t #define fi first #define se second const int INF = 1e16; signed main() { cin.tie(nullptr); ios_base::sync_with_stdio( false ); int n, q, b; vector< int > a; int x, v; int f[300005] = {}, sum = 0; int ans = 0; cin >> n >> q; a.push_back(-1); for ( int i = 0; i < n; i++) { cin >> b; a.push_back(b); } a.push_back(INF); cin >> x >> v; a[x] += v; for ( int i = 1; i < a.size() - 1; i++) { if (a[i] > a[i + 1]) { f[i] = 1; sum++; } } if (sum == 0) ans++; for ( int i = 1; i < q; i++) { cin >> x >> v; a[x] += v; if (a[x] > a[x + 1]) { if (f[x] != 1) sum++; f[x] = 1; } else { if (f[x] != 0) sum--; f[x] = 0; } if (a[x - 1] > a[x]) { if (f[x - 1] != 1) sum++; f[x - 1] = 1; } else { if (f[x - 1] != 0) sum--; f[x - 1] = 0; } if (sum == 0) ans++; } cout << ans << "\n" ; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1530 - Increasing Sequence 2 |
ユーザー名 | ei1941 |
投稿日時 | 2021-09-27 18:23:11 |
言語 | C++14 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 1041 Byte |
最大実行時間 | 100 ms |
最大メモリ使用量 | 9340 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 29 ms | 2908 KB |
1
|
in02.txt | AC | 29 ms | 2828 KB |
1
|
in03.txt | AC | 21 ms | 2752 KB |
1
|
in04.txt | AC | 23 ms | 2800 KB |
1
|
in05.txt | AC | 22 ms | 2852 KB |
1
|
in06.txt | AC | 28 ms | 3028 KB |
1
|
in07.txt | AC | 16 ms | 3020 KB |
1
|
in08.txt | AC | 22 ms | 3004 KB |
1
|
in09.txt | AC | 27 ms | 3036 KB |
1
|
in10.txt | AC | 22 ms | 2924 KB |
1
|
in11.txt | AC | 34 ms | 4056 KB |
1
|
in12.txt | AC | 48 ms | 5108 KB |
1
|
in13.txt | AC | 31 ms | 4040 KB |
1
|
in14.txt | AC | 53 ms | 5000 KB |
1
|
in15.txt | AC | 81 ms | 7552 KB |
1
|
in16.txt | AC | 100 ms | 8476 KB |
1
|
in17.txt | AC | 92 ms | 8376 KB |
1
|
in18.txt | AC | 86 ms | 8160 KB |
1
|
in19.txt | AC | 83 ms | 8176 KB |
1
|
in20.txt | AC | 89 ms | 8672 KB |
1
|
in21.txt | AC | 74 ms | 7216 KB |
1
|
in22.txt | AC | 87 ms | 7968 KB |
1
|
in23.txt | AC | 72 ms | 7388 KB |
1
|
in24.txt | AC | 87 ms | 8168 KB |
1
|
in25.txt | AC | 74 ms | 7252 KB |
1
|
in26.txt | AC | 73 ms | 7236 KB |
1
|
in27.txt | AC | 83 ms | 7128 KB |
1
|
in28.txt | AC | 53 ms | 2912 KB |
1
|
in29.txt | AC | 84 ms | 9340 KB |
1
|
in30.txt | AC | 74 ms | 8732 KB |
1
|
in31.txt | AC | 80 ms | 8256 KB |
1
|
in32.txt | AC | 68 ms | 7364 KB |
1
|
in33.txt | AC | 82 ms | 7228 KB |
1
|
in34.txt | AC | 74 ms | 8236 KB |
1
|
in35.txt | AC | 55 ms | 3420 KB |
1
|
in36.txt | AC | 76 ms | 8376 KB |
1
|
sample.txt | AC | 30 ms | 2960 KB |
1
|