| Task: | Maalarit |
| Sender: | ollpu |
| Submission time: | 2016-10-03 22:29:23 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| #4 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.04 s | 1 | details |
| #2 | WRONG ANSWER | 0.06 s | 1 | details |
| #3 | WRONG ANSWER | 0.06 s | 1 | details |
| #4 | WRONG ANSWER | 0.05 s | 1 | details |
| #5 | WRONG ANSWER | 0.05 s | 1 | details |
| #6 | WRONG ANSWER | 0.06 s | 1 | details |
| #7 | WRONG ANSWER | 0.06 s | 2 | details |
| #8 | WRONG ANSWER | 0.06 s | 2 | details |
| #9 | WRONG ANSWER | 0.06 s | 2 | details |
| #10 | WRONG ANSWER | 0.05 s | 2 | details |
| #11 | WRONG ANSWER | 0.06 s | 2 | details |
| #12 | WRONG ANSWER | 0.05 s | 2 | details |
| #13 | WRONG ANSWER | 0.06 s | 3 | details |
| #14 | WRONG ANSWER | 0.05 s | 3 | details |
| #15 | WRONG ANSWER | 0.05 s | 3 | details |
| #16 | WRONG ANSWER | 0.05 s | 3 | details |
| #17 | WRONG ANSWER | 0.05 s | 3 | details |
| #18 | WRONG ANSWER | 0.06 s | 3 | details |
| #19 | WRONG ANSWER | 0.18 s | 4 | details |
| #20 | WRONG ANSWER | 0.16 s | 4 | details |
| #21 | WRONG ANSWER | 0.18 s | 4 | details |
| #22 | WRONG ANSWER | 0.17 s | 4 | details |
| #23 | WRONG ANSWER | 0.17 s | 4 | details |
| #24 | WRONG ANSWER | 0.14 s | 4 | details |
Code
#include <iostream>
#include <algorithm>
#define inf 1.1e9
#define F first
#define S second
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
long t[n];
pair<long,long> dp[n+1][4];
dp[n][0] = {0,0};
dp[n][1] = {0,0};
dp[n][2] = {inf,0};
dp[n][3] = {inf,0};
for (int i = 0; i < n; ++i) {
cin >> t[i];
}
int f = 0;
for (int i = n-1; i >= 0; --i) {
long a = max(t[i], dp[i+1][1].F)+dp[i+1][1].S,
b = max(t[i], dp[i+1][0].F)+dp[i+1][0].S,
c = max(t[i], dp[i+1][3].F)+dp[i+1][3].S,
d = max(t[i], dp[i+1][2].F)+dp[i+1][2].S;
if (a + b <= c + d) {
dp[i][0] = {max(t[i]*((i+f)%2), dp[i+1][0].F), dp[i+1][0].S};
dp[i][1] = {max(t[i]*!((i+f)%2), dp[i+1][1].F), dp[i+1][1].S};
} else {
f++;
dp[i][0] = {max(t[i]*((i+f)%2), dp[i+1][3].F), dp[i+1][3].S};
dp[i][1] = {max(t[i]*!((i+f)%2), dp[i+1][2].F), dp[i+1][2].S};
}
dp[i][2] = {dp[i+1][0].F, max(t[i], dp[i+1][0].S)};
dp[i][3] = {dp[i+1][1].F, max(t[i], dp[i+1][1].S)};
}
cout << "A B X Y" << endl;
for (int i = 0; i < n; ++i) {
cout << dp[i][0].F << '|' << dp[i][0].S << ' ' << dp[i][1].F << '|' << dp[i][1].S << ' ' << dp[i][2].F << '|' << dp[i][2].S << ' ' << dp[i][3].F << '|' << dp[i][3].S << endl;
}
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 22 54 3 91 69 90 40 29 83 71 |
| correct output |
|---|
| 174 3 2 1 2 1 2 1 2 1 2 1 |
| user output |
|---|
| A B X Y 91|0 83|0 91|22 83|22 91|0 83|0 91|54 83|54 91|0 83|0 91|3 83|3 91|0 83|0 90|91 83|91 ... |
Test 2
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 49 3 96 38 90 18 92 74 83 1 |
| correct output |
|---|
| 170 3 1 2 1 2 1 2 1 2 1 2 |
| user output |
|---|
| A B X Y 74|0 96|0 74|49 96|49 74|0 96|0 74|3 96|3 74|0 96|0 74|96 92|96 74|0 92|0 74|38 92|38 ... |
Test 3
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 46 3 41 30 16 17 12 93 80 81 |
| correct output |
|---|
| 173 3 2 1 2 1 2 1 2 1 2 1 |
| user output |
|---|
| A B X Y 93|0 80|0 93|46 80|46 93|0 80|0 93|3 80|3 93|0 80|0 93|41 80|41 93|0 80|0 93|30 80|30 ... |
Test 4
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 46 8 95 85 82 73 82 92 53 90 |
| correct output |
|---|
| 187 3 1 2 1 2 1 2 1 2 1 2 |
| user output |
|---|
| A B X Y 92|0 95|0 92|46 95|46 92|0 95|0 92|8 95|8 92|0 95|0 92|95 82|95 92|0 82|0 92|85 82|85 ... |
Test 5
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 41 18 61 59 40 96 5 2 74 38 |
| correct output |
|---|
| 159 3 2 1 2 1 2 1 2 3 1 2 |
| user output |
|---|
| A B X Y 96|0 74|0 96|41 74|41 96|0 74|0 96|18 74|18 96|0 74|0 96|61 74|61 96|0 74|0 96|59 74|59 ... |
Test 6
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 1 1 1 1 1 1 1 1 1 |
| correct output |
|---|
| 2 3 2 1 2 1 2 1 2 1 2 1 |
| user output |
|---|
| A B X Y 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 ... |
Test 7
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 1 39 94 5 24 84 84 10 78 61 38... |
| correct output |
|---|
| 193 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 95|0 98|0 95|1 98|1 95|0 98|0 95|39 98|39 95|0 98|0 95|94 98|94 95|0 98|0 95|5 98|5 ... |
Test 8
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 31 73 18 88 49 28 66 5 32 48 9... |
| correct output |
|---|
| 199 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 100|0 99|0 100|31 99|31 100|0 99|0 100|73 99|73 100|0 99|0 100|18 99|18 100|0 99|0 100|88 99|88 ... |
Test 9
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 45 56 36 60 31 10 23 79 29 17 ... |
| correct output |
|---|
| 198 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 98|0 100|0 98|45 100|45 98|0 100|0 98|56 100|56 98|0 100|0 98|36 100|36 98|0 100|0 98|60 100|60 ... |
Test 10
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 1 77 70 62 21 68 40 54 90 62 1... |
| correct output |
|---|
| 194 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 94|0 100|0 94|1 100|1 94|0 100|0 94|77 100|77 94|0 100|0 94|70 100|70 94|0 100|0 94|62 100|62 ... |
Test 11
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 4 47 41 81 56 64 12 10 20 100 ... |
| correct output |
|---|
| 189 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 100|0 97|0 100|4 97|4 100|0 97|0 100|47 97|47 100|0 97|0 100|41 97|41 100|0 97|0 100|81 97|81 ... |
Test 12
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 1 1 1 1 1 1 1 1 1 |
| correct output |
|---|
| 2 3 2 1 2 1 2 1 2 1 2 1 |
| user output |
|---|
| A B X Y 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 ... |
Test 13
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 256160448 813097800 167146270 ... |
| correct output |
|---|
| 1929869257 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 953135612|0 976733645|0 953135... |
Test 14
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 520002672 3542567 24668528 959... |
| correct output |
|---|
| 1946957555 3 1 2 3 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 966968228|0 987643930|0 966968... |
Test 15
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 483158423 780224665 844754665 ... |
| correct output |
|---|
| 1959373560 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 993180779|0 988997474|0 993180... |
Test 16
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 969647264 128558017 889036329 ... |
| correct output |
|---|
| 1997942264 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 999253493|0 998688771|0 999253... |
Test 17
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 745018527 400495893 635468795 ... |
| correct output |
|---|
| 1961391143 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 994767963|0 991487502|0 994767... |
Test 18
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 1 1 1 1 1 1 1 1 1 |
| correct output |
|---|
| 2 3 2 1 2 1 2 1 2 1 2 1 |
| user output |
|---|
| A B X Y 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 ... |
Test 19
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 197349274 775463806 263930657 ... |
| correct output |
|---|
| 1999942635 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 999994958|0 999969009|0 999994... |
Test 20
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 102296405 34648120 320393597 9... |
| correct output |
|---|
| 1999930943 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
| user output |
|---|
| A B X Y 999995191|0 999984321|0 999995... |
Test 21
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 781254921 418252056 502363453 ... |
| correct output |
|---|
| 1999987794 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 999993394|0 999994400|0 999993... |
Test 22
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 849784881 230439009 455097426 ... |
| correct output |
|---|
| 1999979439 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 999987232|0 999992207|0 999987... |
Test 23
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 851456132 13422224 537539701 4... |
| correct output |
|---|
| 1999948226 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| A B X Y 999963330|0 999984896|0 999963... |
Test 24
Group: 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 2 3 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 ... |
| user output |
|---|
| A B X Y 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 1|0 1|0 1|1 1|1 ... |
