QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876417#4269. Rainy Marketshhoppitree0 162ms19536kbC++17881b2025-01-30 21:05:412025-01-30 21:05:41

Judging History

This is the latest submission verdict.

  • [2025-01-30 21:05:41]
  • Judged
  • Verdict: 0
  • Time: 162ms
  • Memory: 19536kb
  • [2025-01-30 21:05:41]
  • Submitted

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 = max(min(b[i] - a[i], f[i + 1]), 0);
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

3
10 15 10
20 20
0 0

output:

NO

result:

ok IMPOSSIBLE

Test #2:

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

input:

2
813741488 132495829
946237313
0

output:

YES
0
813741488 0 132495825

result:

ok good plan

Test #3:

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

input:

2
175700937 435906025
546265275
0

output:

YES
0
175700937 0 370564338

result:

ok good plan

Test #4:

score: 5
Accepted
time: 146ms
memory: 19440kb

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: 162ms
memory: 19536kb

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: 144ms
memory: 16340kb

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: 161ms
memory: 16364kb

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: 1ms
memory: 10056kb

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: 10060kb

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
-98237770449
272373873 0 25945708
114751603 0 692287352
243604620 -20444904 0
459510485 -39014318 0
380217614 0 586382179
302833388 0 259549219
592757482 0 155581828
816221965 -1615592 0
240167795 -82292605 0
156812678 0 64831972
365820934 0 631588619
679867620 0 132962752
875382020 -61265986 0
...

result:

wrong answer the cost you declared is -98237770449, but expected 0

Subtask #2:

score: 0
Wrong Answer

Test #36:

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

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: 10056kb

input:

2
25 58
103
25

output:

YES
20
25 20 58

result:

ok good plan

Test #39:

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

input:

2
400 400
121
200

output:

YES
-279
400 -279 0

result:

wrong answer the cost you declared is -279, but expected 0

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%