Task: | Kemija |
Sender: | untokarila |
Submission time: | 2019-07-31 15:48:13 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | WRONG ANSWER | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | WRONG ANSWER | 0.01 s | details |
#8 | ACCEPTED | 0.01 s | details |
#9 | ACCEPTED | 0.01 s | details |
#10 | WRONG ANSWER | 0.01 s | details |
Code
#include <iostream> #include <algorithm> #include <cstdlib> #define F first #define S second using namespace std; int n, a[101010], ans[101010]; int pos(int x){ if(x >= n) return x-n; if(x < 0) return n-x; return x; } bool valid(int num, int pr){ int ind = 0; for(int i=0; i<n; i++) ans[i] = 0; do{ ans[ind] = num; if(ans[pos(ind-1)]+ans[ind]+ans[pos(ind+1)] > a[ind]) return 0; num += a[pos(ind+2)]-a[pos(ind+1)]; ind = pos(ind+3); } while(ind); if(pr) for(int i=0; i<n; i++) cout << ans[i] << ' '; return 1; } int main(){ cin >> n; for(int i=0; i<n; i++) cin >> a[i]; int k=0; for(int b=1e9; b>=1; b/=2){ while(valid(k+b, 0)) k+=b; } valid(k, 1); return 0; } /*/ 6 9 6 9 12 15 12 /*/
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3
53 53 53 |
correct output |
---|
1
1 51 |
user output |
---|
53 0 0 |
Test 2
Verdict: ACCEPTED
input |
---|
5
8 9 12 9 ... |
correct output |
---|
1
5 3 4 2 |
user output |
---|
1 5 3 4 2 |
Test 3
Verdict: ACCEPTED
input |
---|
7
8 4 8 10 ... |
correct output |
---|
1
2 1 5 4 ... |
user output |
---|
1 2 1 5 4 4 5 |
Test 4
Verdict: WRONG ANSWER
input |
---|
9
6 10 11 13 ... |
correct output |
---|
1
3 6 2 5 ... |
user output |
---|
6 0 0 7 0 0 7 0 0 |
Test 5
Verdict: ACCEPTED
input |
---|
11
14 15 15 12 ... |
correct output |
---|
2
9 4 2 6 ... |
user output |
---|
2 9 4 2 6 13 8 11 13 3 3 |
Test 6
Verdict: ACCEPTED
input |
---|
43
49 43 27 20 ... |
correct output |
---|
17
20 6 1 13 ... |
user output |
---|
17 20 6 1 13 2 10 16 13 12 5 1... Truncated |
Test 7
Verdict: WRONG ANSWER
input |
---|
99
61 55 64 67 ... |
correct output |
---|
10
20 25 19 23 ... |
user output |
---|
18 0 0 27 0 0 25 0 0 11 0 0 25... Truncated |
Test 8
Verdict: ACCEPTED
input |
---|
500
34234 24097 6848 24240 ... |
correct output |
---|
18019
5147 931 770 22539 ... |
user output |
---|
18019 5147 931 770 22539 8231 ... Truncated |
Test 9
Verdict: ACCEPTED
input |
---|
5002
257175927 192486676 334121373 435149455 ... |
correct output |
---|
146582420
29055198 16849058 288217117 130083280 ... |
user output |
---|
146582420 29055198 16849058 28... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
9999
352949139 551279904 517124120 806539504 ... |
correct output |
---|
239036611
37116744 275126549 204880827 326532128 ... |
user output |
---|
248794107 0 0 214638323 0 0 19... Truncated |