답안 #971458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971458 2024-04-28T14:31:13 Z KiaRez Rainy Markets (CCO22_day1problem2) C++17
25 / 25
474 ms 106980 KB
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

const int N = 1e6+23, lg = 18;
ll Mod = 1e9+7; //998244353;

inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
    ll ans = 1;
    a=MOD(a, mod);
    while (b) {
        if (b & 1) ans = MOD(ans*a, mod);
        b >>= 1;
        a = MOD(a*a, mod);
    }
    return ans;
}

ll n, ans, res[3][N], b[N], p[N], u[N], dp[N], par[N];
// 0->l 1->mid 2->r
int main () {
	ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n;
    for(int i=1; i<=n; i++) cin>>b[i];
    for(int i=1; i<=n-1; i++) cin>>p[i];
    for(int i=1; i<=n-1; i++) cin>>u[i];

    for(int i=1; i<n; i++) {
        ll tmp = min(b[i]-res[2][i-1], p[i]);
        p[i] -= tmp; res[0][i] = tmp;
        tmp = min(u[i], p[i]);
        p[i] -= tmp; res[1][i] = tmp;
        tmp = min(b[i+1], p[i]);
        p[i] -= tmp; res[2][i] = tmp;
    }

    for(int i=n-1; i>=1; i--) {
        ll tmp = min(res[1][i], b[i+1]-res[2][i]-res[0][i+1]);
        res[1][i] -= tmp; res[2][i] += tmp;
        tmp = min(res[0][i], b[i+1]-res[2][i]-res[0][i+1]);
        res[0][i] -= tmp; res[2][i] += tmp;
    }

    for(int i=1; i<=n; i++) {
        if(p[i] > 0) {
            cout<<"NO\n";
            return 0;
        }
        ans += res[1][i];
    }

    cout<<"YES\n";
    cout<<ans<<endl;
    for(int i=1; i<n; i++) {
        cout<<res[0][i]<<' '<<res[1][i]<<' '<<res[2][i]<<endl;
    }

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10584 KB Output is correct
2 Correct 2 ms 10584 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 173 ms 48332 KB Output is correct
5 Correct 198 ms 69812 KB Output is correct
6 Correct 172 ms 64104 KB Output is correct
7 Correct 238 ms 69832 KB Output is correct
8 Correct 3 ms 12892 KB Output is correct
9 Correct 3 ms 12768 KB Output is correct
10 Correct 265 ms 61000 KB Output is correct
11 Correct 318 ms 64084 KB Output is correct
12 Correct 381 ms 89832 KB Output is correct
13 Correct 371 ms 85000 KB Output is correct
14 Correct 169 ms 63316 KB Output is correct
15 Correct 389 ms 91708 KB Output is correct
16 Correct 384 ms 91988 KB Output is correct
17 Correct 381 ms 91700 KB Output is correct
18 Correct 387 ms 91976 KB Output is correct
19 Correct 380 ms 91728 KB Output is correct
20 Correct 396 ms 91584 KB Output is correct
21 Correct 389 ms 91740 KB Output is correct
22 Correct 408 ms 89024 KB Output is correct
23 Correct 406 ms 91396 KB Output is correct
24 Correct 413 ms 91220 KB Output is correct
25 Correct 199 ms 70124 KB Output is correct
26 Correct 218 ms 70076 KB Output is correct
27 Correct 387 ms 91824 KB Output is correct
28 Correct 377 ms 89940 KB Output is correct
29 Correct 381 ms 91988 KB Output is correct
30 Correct 392 ms 91872 KB Output is correct
31 Correct 375 ms 90452 KB Output is correct
32 Correct 383 ms 91744 KB Output is correct
33 Correct 198 ms 70020 KB Output is correct
34 Correct 207 ms 70232 KB Output is correct
35 Correct 202 ms 69972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 2 ms 10724 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 2 ms 10728 KB Output is correct
6 Correct 2 ms 10588 KB Output is correct
7 Correct 2 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 2 ms 10716 KB Output is correct
11 Correct 2 ms 10584 KB Output is correct
12 Correct 2 ms 10588 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10760 KB Output is correct
19 Correct 3 ms 10760 KB Output is correct
20 Correct 2 ms 10584 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 3 ms 10588 KB Output is correct
23 Correct 2 ms 10716 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10588 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 3 ms 10588 KB Output is correct
29 Correct 2 ms 10584 KB Output is correct
30 Correct 2 ms 10584 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 10588 KB Output is correct
34 Correct 2 ms 10588 KB Output is correct
35 Correct 2 ms 10728 KB Output is correct
36 Correct 2 ms 10588 KB Output is correct
37 Correct 2 ms 10724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 2 ms 10724 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 2 ms 10728 KB Output is correct
6 Correct 2 ms 10588 KB Output is correct
7 Correct 2 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 2 ms 10716 KB Output is correct
11 Correct 2 ms 10584 KB Output is correct
12 Correct 2 ms 10588 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10760 KB Output is correct
19 Correct 3 ms 10760 KB Output is correct
20 Correct 2 ms 10584 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 3 ms 10588 KB Output is correct
23 Correct 2 ms 10716 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10588 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 3 ms 10588 KB Output is correct
29 Correct 2 ms 10584 KB Output is correct
30 Correct 2 ms 10584 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 10588 KB Output is correct
34 Correct 2 ms 10588 KB Output is correct
35 Correct 2 ms 10728 KB Output is correct
36 Correct 2 ms 10588 KB Output is correct
37 Correct 2 ms 10724 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12632 KB Output is correct
40 Correct 2 ms 12636 KB Output is correct
41 Correct 2 ms 12636 KB Output is correct
42 Correct 2 ms 10588 KB Output is correct
43 Correct 2 ms 10588 KB Output is correct
44 Correct 2 ms 12636 KB Output is correct
45 Correct 3 ms 12636 KB Output is correct
46 Correct 2 ms 12636 KB Output is correct
47 Correct 2 ms 12636 KB Output is correct
48 Correct 3 ms 12764 KB Output is correct
49 Correct 3 ms 12892 KB Output is correct
50 Correct 3 ms 12636 KB Output is correct
51 Correct 3 ms 12636 KB Output is correct
52 Correct 3 ms 12896 KB Output is correct
53 Correct 3 ms 12636 KB Output is correct
54 Correct 3 ms 12892 KB Output is correct
55 Correct 3 ms 12892 KB Output is correct
56 Correct 3 ms 12892 KB Output is correct
57 Correct 3 ms 12900 KB Output is correct
58 Correct 3 ms 12892 KB Output is correct
59 Correct 3 ms 12892 KB Output is correct
60 Correct 3 ms 12892 KB Output is correct
61 Correct 3 ms 12900 KB Output is correct
62 Correct 4 ms 12888 KB Output is correct
63 Correct 3 ms 12896 KB Output is correct
64 Correct 3 ms 12632 KB Output is correct
65 Correct 2 ms 12632 KB Output is correct
66 Correct 4 ms 13064 KB Output is correct
67 Correct 3 ms 12892 KB Output is correct
68 Correct 3 ms 12892 KB Output is correct
69 Correct 3 ms 13036 KB Output is correct
70 Correct 3 ms 12888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10584 KB Output is correct
2 Correct 2 ms 10584 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 173 ms 48332 KB Output is correct
5 Correct 198 ms 69812 KB Output is correct
6 Correct 172 ms 64104 KB Output is correct
7 Correct 238 ms 69832 KB Output is correct
8 Correct 3 ms 12892 KB Output is correct
9 Correct 3 ms 12768 KB Output is correct
10 Correct 265 ms 61000 KB Output is correct
11 Correct 318 ms 64084 KB Output is correct
12 Correct 381 ms 89832 KB Output is correct
13 Correct 371 ms 85000 KB Output is correct
14 Correct 169 ms 63316 KB Output is correct
15 Correct 389 ms 91708 KB Output is correct
16 Correct 384 ms 91988 KB Output is correct
17 Correct 381 ms 91700 KB Output is correct
18 Correct 387 ms 91976 KB Output is correct
19 Correct 380 ms 91728 KB Output is correct
20 Correct 396 ms 91584 KB Output is correct
21 Correct 389 ms 91740 KB Output is correct
22 Correct 408 ms 89024 KB Output is correct
23 Correct 406 ms 91396 KB Output is correct
24 Correct 413 ms 91220 KB Output is correct
25 Correct 199 ms 70124 KB Output is correct
26 Correct 218 ms 70076 KB Output is correct
27 Correct 387 ms 91824 KB Output is correct
28 Correct 377 ms 89940 KB Output is correct
29 Correct 381 ms 91988 KB Output is correct
30 Correct 392 ms 91872 KB Output is correct
31 Correct 375 ms 90452 KB Output is correct
32 Correct 383 ms 91744 KB Output is correct
33 Correct 198 ms 70020 KB Output is correct
34 Correct 207 ms 70232 KB Output is correct
35 Correct 202 ms 69972 KB Output is correct
36 Correct 2 ms 10588 KB Output is correct
37 Correct 2 ms 10724 KB Output is correct
38 Correct 2 ms 10588 KB Output is correct
39 Correct 2 ms 10588 KB Output is correct
40 Correct 2 ms 10728 KB Output is correct
41 Correct 2 ms 10588 KB Output is correct
42 Correct 2 ms 10588 KB Output is correct
43 Correct 2 ms 10588 KB Output is correct
44 Correct 2 ms 10588 KB Output is correct
45 Correct 2 ms 10716 KB Output is correct
46 Correct 2 ms 10584 KB Output is correct
47 Correct 2 ms 10588 KB Output is correct
48 Correct 2 ms 10588 KB Output is correct
49 Correct 2 ms 10588 KB Output is correct
50 Correct 2 ms 10588 KB Output is correct
51 Correct 2 ms 10588 KB Output is correct
52 Correct 2 ms 10588 KB Output is correct
53 Correct 2 ms 10760 KB Output is correct
54 Correct 3 ms 10760 KB Output is correct
55 Correct 2 ms 10584 KB Output is correct
56 Correct 2 ms 10588 KB Output is correct
57 Correct 3 ms 10588 KB Output is correct
58 Correct 2 ms 10716 KB Output is correct
59 Correct 2 ms 10588 KB Output is correct
60 Correct 2 ms 10588 KB Output is correct
61 Correct 2 ms 10588 KB Output is correct
62 Correct 2 ms 10588 KB Output is correct
63 Correct 3 ms 10588 KB Output is correct
64 Correct 2 ms 10584 KB Output is correct
65 Correct 2 ms 10584 KB Output is correct
66 Correct 2 ms 10588 KB Output is correct
67 Correct 2 ms 10588 KB Output is correct
68 Correct 2 ms 10588 KB Output is correct
69 Correct 2 ms 10588 KB Output is correct
70 Correct 2 ms 10728 KB Output is correct
71 Correct 2 ms 10588 KB Output is correct
72 Correct 2 ms 10724 KB Output is correct
73 Correct 4 ms 12892 KB Output is correct
74 Correct 2 ms 12632 KB Output is correct
75 Correct 2 ms 12636 KB Output is correct
76 Correct 2 ms 12636 KB Output is correct
77 Correct 2 ms 10588 KB Output is correct
78 Correct 2 ms 10588 KB Output is correct
79 Correct 2 ms 12636 KB Output is correct
80 Correct 3 ms 12636 KB Output is correct
81 Correct 2 ms 12636 KB Output is correct
82 Correct 2 ms 12636 KB Output is correct
83 Correct 3 ms 12764 KB Output is correct
84 Correct 3 ms 12892 KB Output is correct
85 Correct 3 ms 12636 KB Output is correct
86 Correct 3 ms 12636 KB Output is correct
87 Correct 3 ms 12896 KB Output is correct
88 Correct 3 ms 12636 KB Output is correct
89 Correct 3 ms 12892 KB Output is correct
90 Correct 3 ms 12892 KB Output is correct
91 Correct 3 ms 12892 KB Output is correct
92 Correct 3 ms 12900 KB Output is correct
93 Correct 3 ms 12892 KB Output is correct
94 Correct 3 ms 12892 KB Output is correct
95 Correct 3 ms 12892 KB Output is correct
96 Correct 3 ms 12900 KB Output is correct
97 Correct 4 ms 12888 KB Output is correct
98 Correct 3 ms 12896 KB Output is correct
99 Correct 3 ms 12632 KB Output is correct
100 Correct 2 ms 12632 KB Output is correct
101 Correct 4 ms 13064 KB Output is correct
102 Correct 3 ms 12892 KB Output is correct
103 Correct 3 ms 12892 KB Output is correct
104 Correct 3 ms 13036 KB Output is correct
105 Correct 3 ms 12888 KB Output is correct
106 Correct 2 ms 10584 KB Output is correct
107 Correct 1 ms 10588 KB Output is correct
108 Correct 348 ms 79828 KB Output is correct
109 Correct 376 ms 88912 KB Output is correct
110 Correct 341 ms 79836 KB Output is correct
111 Correct 378 ms 88956 KB Output is correct
112 Correct 3 ms 12888 KB Output is correct
113 Correct 4 ms 13024 KB Output is correct
114 Correct 471 ms 106800 KB Output is correct
115 Correct 425 ms 103224 KB Output is correct
116 Correct 317 ms 60752 KB Output is correct
117 Correct 315 ms 65228 KB Output is correct
118 Correct 430 ms 93916 KB Output is correct
119 Correct 162 ms 62520 KB Output is correct
120 Correct 445 ms 106476 KB Output is correct
121 Correct 439 ms 106808 KB Output is correct
122 Correct 424 ms 106888 KB Output is correct
123 Correct 435 ms 106828 KB Output is correct
124 Correct 474 ms 106760 KB Output is correct
125 Correct 438 ms 106576 KB Output is correct
126 Correct 427 ms 106388 KB Output is correct
127 Correct 418 ms 101716 KB Output is correct
128 Correct 433 ms 106772 KB Output is correct
129 Correct 435 ms 105408 KB Output is correct
130 Correct 240 ms 77288 KB Output is correct
131 Correct 255 ms 77460 KB Output is correct
132 Correct 438 ms 106436 KB Output is correct
133 Correct 240 ms 77464 KB Output is correct
134 Correct 424 ms 106556 KB Output is correct
135 Correct 434 ms 106980 KB Output is correct
136 Correct 446 ms 104448 KB Output is correct
137 Correct 435 ms 106252 KB Output is correct
138 Correct 268 ms 77340 KB Output is correct
139 Correct 243 ms 77436 KB Output is correct
140 Correct 240 ms 76372 KB Output is correct