Submission #69073


ソースコード

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
53
54
55
56
57
58
59
60
61
62
63
/* #region header */
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0;i < (int)(n);++i)
#define MS(x) memset((x), -1, sizeof((x)))
#define ALL(x) x.begin(), x.end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool is_npos(string::size_type x) { return x == string::npos; }
using PI = pair<int, int>;
template <class T>ostream &operator<<(ostream &os, const vector<T>&v){
if(v.size() > 0){
os << v[0];
for(int i = 1;i < v.size();i++) os << " " << v[i];
}
return os;
}
/* #endregion */
int main(){
int n, q;
cin >> n >> q;
vector<ll> a(n);
vector<bool> b(n);
int bcnt = 0;
rep(i, n){
cin >> a[i];
if(i > 0){
b[i-1] = a[i-1] <= a[i];
if(b[i-1]) bcnt++;
}
}
int ans = 0;
rep(i, q){
ll x, y;
cin >> x >> y;
x--;
a[x] += y;
if(x > 0){
int old = b[x-1];
b[x-1] = a[x-1] <= a[x];
int nw = b[x-1];
bcnt += nw-old;
}
if(x < n-1){
int old = b[x];
b[x] = a[x] <= a[x+1];
int nw = b[x];
bcnt += nw-old;
}
if(bcnt == n-1) ans++;
}
cout << ans << endl;
return 0;
}

ステータス

項目 データ
問題 1530 - Increasing Sequence 2
ユーザー名 ei1719
投稿日時 2021-12-05 23:36:18
言語 C++14
状態 Accepted
得点 3
ソースコード長 1279 Byte
最大実行時間 275 ms
最大メモリ使用量 3092 KB

セット

セット 得点 Cases
1 ALL 3 / 3 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 24 ms 604 KB
1
in02.txt AC 17 ms 452 KB
1
in03.txt AC 21 ms 424 KB
1
in04.txt AC 20 ms 528 KB
1
in05.txt AC 21 ms 364 KB
1
in06.txt AC 16 ms 464 KB
1
in07.txt AC 20 ms 416 KB
1
in08.txt AC 20 ms 492 KB
1
in09.txt AC 17 ms 588 KB
1
in10.txt AC 26 ms 672 KB
1
in11.txt AC 43 ms 1516 KB
1
in12.txt AC 99 ms 2612 KB
1
in13.txt AC 58 ms 1580 KB
1
in14.txt AC 111 ms 2596 KB
1
in15.txt AC 201 ms 2756 KB
1
in16.txt AC 223 ms 2984 KB
1
in17.txt AC 251 ms 3004 KB
1
in18.txt AC 275 ms 3032 KB
1
in19.txt AC 216 ms 3060 KB
1
in20.txt AC 222 ms 3084 KB
1
in21.txt AC 173 ms 2984 KB
1
in22.txt AC 183 ms 3004 KB
1
in23.txt AC 193 ms 3028 KB
1
in24.txt AC 214 ms 2924 KB
1
in25.txt AC 225 ms 2948 KB
1
in26.txt AC 234 ms 2968 KB
1
in27.txt AC 226 ms 2992 KB
1
in28.txt AC 123 ms 580 KB
1
in29.txt AC 190 ms 2984 KB
1
in30.txt AC 201 ms 3004 KB
1
in31.txt AC 180 ms 3028 KB
1
in32.txt AC 183 ms 3048 KB
1
in33.txt AC 196 ms 3068 KB
1
in34.txt AC 186 ms 3092 KB
1
in35.txt AC 139 ms 940 KB
1
in36.txt AC 190 ms 3032 KB
1
sample.txt AC 24 ms 588 KB
1