QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876412#4269. Rainy Marketshhoppitree0 161ms19484kbC++17873b2025-01-30 21:02:162025-01-30 21:02:17

Judging History

你现在查看的是最新测评结果

  • [2025-01-30 21:02:17]
  • 评测
  • 测评结果:0
  • 用时:161ms
  • 内存:19484kb
  • [2025-01-30 21:02:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int a[N], b[N], c[N], f[N];

signed main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i < n; ++i) scanf("%d", &b[i]);
    for (int i = 1; i < n; ++i) scanf("%d", &c[i]);
    f[n] = a[n];
    for (int i = n - 1; i >= 1; --i) {
        f[i] = a[i] - max(b[i] - c[i] - f[i + 1], 0);
        if (f[i] < 0) return 0 & puts("NO");
    }
    vector< array<int, 3> > res;
    for (int i = 1; i < n; ++i) {
        int t = min(b[i] - a[i], f[i + 1]);
        res.push_back({a[i], b[i] - a[i] - t, t});
        a[i + 1] -= t;
    }
	long long S = 0;
	for_each(res.begin(), res.end(), [&](auto x) { S += x[1]; });
	puts("YES"), printf("%lld\n", S);
	for (auto [x, y, z] : res) printf("%d %d %d\n", x, y, z);
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 10064kb

input:

3
10 15 10
20 20
0 0

output:

NO

result:

ok IMPOSSIBLE

Test #2:

score: 5
Accepted
time: 0ms
memory: 10056kb

input:

2
813741488 132495829
946237313
0

output:

YES
0
813741488 0 132495825

result:

ok good plan

Test #3:

score: 5
Accepted
time: 0ms
memory: 9880kb

input:

2
175700937 435906025
546265275
0

output:

YES
0
175700937 0 370564338

result:

ok good plan

Test #4:

score: 5
Accepted
time: 145ms
memory: 19464kb

input:

1000000
999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 99999...

output:

NO

result:

ok IMPOSSIBLE

Test #5:

score: 5
Accepted
time: 161ms
memory: 19484kb

input:

1000000
500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 50...

output:

NO

result:

ok IMPOSSIBLE

Test #6:

score: 5
Accepted
time: 150ms
memory: 17604kb

input:

1000000
999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 999998 99999...

output:

NO

result:

ok IMPOSSIBLE

Test #7:

score: 5
Accepted
time: 158ms
memory: 17012kb

input:

1000000
500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 50...

output:

NO

result:

ok IMPOSSIBLE

Test #8:

score: 5
Accepted
time: 2ms
memory: 10064kb

input:

4000
371896518 731935279 428414487 878930842 569178148 826228818 1000783912 686784551 510567707 203391729 232379073 1351183869 429219170 767480826 351913312 143053268 871061720 171086334 342694087 784356999 505826785 816153880 512894008 199747092 526361485 936149088 572347607 543039867 480605813 967...

output:

YES
0
371896518 0 345249820
386685459 0 362308188
66106299 0 473313580
405617262 0 180574503
388603645 0 458982202
367246616 0 575000419
425783493 0 355865390
330919161 0 379939779
130627928 0 56406124
146985605 0 157230285
75148788 0 770513948
580669921 0 33222618
395996552 0 459383357
308097469 0 ...

result:

ok good plan

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 12112kb

input:

4000
272373873 140697311 935891972 459510485 380217614 889215567 852306701 971803793 240167795 156812678 430652906 1311456239 1008344772 440041142 623974894 450082368 796550780 952767338 836068185 1145186862 273207527 1390469317 568188650 409763894 1342431187 848500582 958109270 564107379 763581098 ...

output:

YES
74617904270
272373873 0 25945708
114751603 0 692287352
243604620 0 -20444904
479955389 0 -59459222
439676836 0 526922957
362292610 0 200089997
652216704 0 96122606
875681187 0 -61074814
301242609 0 -143367419
300180097 0 -78535447
509188353 0 488221200
823235039 0 -10404667
1018749439 0 -2046334...

result:

wrong answer the cost you declared is 74617904270, but expected 0

Subtask #2:

score: 0
Wrong Answer

Test #36:

score: 5
Accepted
time: 0ms
memory: 10012kb

input:

3
10 15 10
20 20
0 11

output:

YES
5
10 0 10
5 5 10

result:

ok good plan

Test #37:

score: 5
Accepted
time: 0ms
memory: 10060kb

input:

4
5 3 1 2
7 6 2
3 2 4

output:

YES
4
5 2 0
3 2 1
0 0 2

result:

ok good plan

Test #38:

score: 5
Accepted
time: 0ms
memory: 10060kb

input:

2
25 58
103
25

output:

YES
20
25 20 58

result:

ok good plan

Test #39:

score: 5
Accepted
time: 0ms
memory: 10192kb

input:

2
400 400
121
200

output:

YES
0
400 0 -279

result:

ok good plan

Test #40:

score: 5
Accepted
time: 0ms
memory: 10060kb

input:

2000
98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 9...

output:

NO

result:

ok IMPOSSIBLE

Test #41:

score: 5
Accepted
time: 1ms
memory: 10064kb

input:

2000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...

output:

NO

result:

ok IMPOSSIBLE

Test #42:

score: 5
Accepted
time: 0ms
memory: 10060kb

input:

2000
98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 9...

output:

NO

result:

ok IMPOSSIBLE

Test #43:

score: 5
Accepted
time: 1ms
memory: 10060kb

input:

2000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...

output:

NO

result:

ok IMPOSSIBLE

Test #44:

score: 5
Accepted
time: 1ms
memory: 10060kb

input:

2000
10 223 62 131 212 90 80 177 228 126 130 34 80 160 102 92 116 83 137 43 167 62 113 115 225 26 179 65 208 108 137 124 71 169 36 101 122 203 36 162 156 89 222 205 138 158 84 178 63 169 31 301 66 158 110 17 211 171 39 46 81 22 110 108 127 49 137 90 137 55 75 60 32 189 52 160 69 145 65 145 56 223 15...

output:

YES
94956
10 0 162
61 13 60
2 90 107
24 59 110
102 19 69
21 56 80
0 36 153
24 10 125
103 34 57
69 11 110
20 5 34
0 21 49
31 20 136
24 9 51
51 26 92
0 21 92
24 66 77
6 69 41
96 4 43
0 10 121
46 18 46
16 55 113
0 45 115
0 8 181
44 87 26
0 31 124
55 55 65
0 29 132
76 7 50
58 31 77
60 15 94
30 79 70
1 2...

result:

ok good plan

Test #45:

score: 5
Accepted
time: 1ms
memory: 10060kb

input:

2000
400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400...

output:

YES
0
400 0 -226
626 0 -501
901 0 -730
1130 0 -958
1358 0 -1172
1572 0 -1393
1793 0 -1614
2014 0 -1846
2246 0 -2098
2498 0 -2340
2740 0 -2601
3001 0 -2810
3210 0 -3054
3454 0 -3254
3654 0 -3586
3986 0 -3873
4273 0 -4181
4581 0 -4422
4822 0 -4755
5155 0 -4969
5369 0 -5245
5645 0 -5502
5902 0 -5813
62...

result:

ok good plan

Test #46:

score: 0
Wrong Answer
time: 0ms
memory: 10056kb

input:

2000
7 6 7 3 7 4 13 8 3 0 4 9 7 5 1 13 3 9 3 9 3 3 6 4 9 5 12 1 3 7 5 6 4 4 11 4 4 4 3 11 2 9 12 4 3 4 7 6 6 10 7 6 9 10 8 6 8 8 6 7 2 5 10 5 5 5 6 5 9 4 7 5 8 3 9 12 13 4 10 3 4 7 3 6 6 7 7 4 8 3 6 2 5 2 6 7 4 5 11 7 2 4 10 2 7 8 8 1 8 10 5 8 1 6 11 4 10 10 3 1 9 6 9 13 5 4 10 5 8 9 3 6 2 9 7 6 8 1...

output:

YES
3375
7 0 3
3 0 6
1 2 3
0 0 3
4 0 3
1 0 9
4 0 5
3 4 2
1 6 0
0 4 4
0 1 9
0 1 7
0 1 3
2 4 1
0 1 9
4 3 3
0 1 8
1 1 3
0 0 8
1 3 3
0 0 1
2 1 6
0 5 4
0 1 9
0 0 5
0 0 8
4 5 1
0 0 3
0 0 7
0 1 5
0 4 5
1 3 4
0 2 4
0 0 7
4 0 4
0 3 4
0 4 4
0 4 3
0 0 6
5 0 2
0 0 7
2 0 5
7 0 3
1 2 3
0 2 4
0 0 7
0 2 6
0 0 6
0 0...

result:

wrong answer the cost you declared is 3375, but expected 3379

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%