//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
void solve(){
int N, Q; cin >> N >> Q;
vector<int> v(N), ans(N, 0);
vector<pii> snow(N + 1);
for(auto &x:v) cin >> x;
for(int i = 0; i <= N; ++i){
int l = (i == 0 ? -2e17 : v[i - 1]), r = (i == N ? 2e17 : v[i]);
snow[i] = pii(l, r);
}
while(Q--){
int w; cin >> w;
if(w > 0){
for(int i = 0; i < N; ++i){
v[i] += w;
if(snow[i + 1].ff < v[i] && snow[i + 1].ss - snow[i + 1].ff > 0){
ans[i] += min(snow[i + 1].ss - snow[i + 1].ff, v[i] - snow[i + 1].ff);
snow[i + 1].ff = v[i];
}
}
}else{
for(int i = 0; i < N; ++i){
v[i] += w;
if(snow[i].ss > v[i] && snow[i].ss - snow[i].ff > 0){
ans[i] += min(snow[i].ss - snow[i].ff ,snow[i].ss - v[i]);
snow[i].ss = v[i];
}
}
}
}
for(int x:ans) cout << x << '\n';
}
signed main(){
starburst
int t = 1; //cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
12 ms |
432 KB |
Output is correct |
5 |
Correct |
12 ms |
340 KB |
Output is correct |
6 |
Correct |
12 ms |
332 KB |
Output is correct |
7 |
Correct |
13 ms |
328 KB |
Output is correct |
8 |
Correct |
12 ms |
340 KB |
Output is correct |
9 |
Correct |
12 ms |
424 KB |
Output is correct |
10 |
Correct |
9 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
12 ms |
340 KB |
Output is correct |
16 |
Correct |
16 ms |
340 KB |
Output is correct |
17 |
Correct |
13 ms |
424 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
12 ms |
432 KB |
Output is correct |
5 |
Correct |
12 ms |
340 KB |
Output is correct |
6 |
Correct |
12 ms |
332 KB |
Output is correct |
7 |
Correct |
13 ms |
328 KB |
Output is correct |
8 |
Correct |
12 ms |
340 KB |
Output is correct |
9 |
Correct |
12 ms |
424 KB |
Output is correct |
10 |
Correct |
9 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
12 ms |
340 KB |
Output is correct |
16 |
Correct |
16 ms |
340 KB |
Output is correct |
17 |
Correct |
13 ms |
424 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
7 ms |
340 KB |
Output is correct |
20 |
Correct |
28 ms |
2328 KB |
Output is correct |
21 |
Correct |
31 ms |
2204 KB |
Output is correct |
22 |
Correct |
95 ms |
1956 KB |
Output is correct |
23 |
Correct |
1060 ms |
1856 KB |
Output is correct |
24 |
Execution timed out |
2522 ms |
1440 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |