CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:Kyselyt
Sender:Mahtimursu
Submission time:2020-10-16 22:10:37 +0300
Language:C++ (C++11)
Status:READY
Result:12
Feedback
groupverdictscore
#1ACCEPTED12
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2--2, 3details
#3--3details
#4--3details
#5--3details

Code

#include <bits/stdc++.h>
typedef long long ll;
#define M 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
}
for (int i = 0; i < q; ++i) {
int a, b;
cin >> a >> b;
a--; b--;
int ans = 0;
int val = v[a];
for (int j = a; j <= b; ++j) {
ans += max(0, val - v[j]);
val = max(val, v[j]);
}
cout << ans << endl;
}
return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100
70 8 72 88 42 78 85 41 23 36 6...

correct output
99
0
922
2579
1892
...

user output
99
0
922
2579
1892
...
Truncated

Test 2

Group: 2, 3

Verdict:

input
200000 200000
98 99 29 92 29 81 100 52 89 80...

correct output
1497732
2810356
9532632
6655773
5403513
...

user output
(empty)

Test 3

Group: 3

Verdict:

input
200000 200000
818377786 934884634 816080381 ...

correct output
86877225712611
94684086875470
92703793485296
38149694892093
61948503092286
...

user output
(empty)

Test 4

Group: 3

Verdict:

input
200000 200000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
0
0
0
0
0
...

user output
(empty)

Test 5

Group: 3

Verdict:

input
200000 200000
200000 199999 199998 199997 19...

correct output
15920862903
3193483321
18874982071
4846348926
3970697055
...

user output
(empty)