답안 #522247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522247 2022-02-04T09:42:49 Z AdamGS Snowball (JOI21_ho_t2) C++17
100 / 100
102 ms 15324 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
ll T[LIM], W[LIM], mi[LIM], ma[LIM], ans[LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, q;
	cin >> n >> q;
	rep(i, n) cin >> T[i];
	ll sum=0;
	rep(i, q) {
		cin >> W[i];
		sum+=W[i];
		mi[i+1]=min(mi[i], sum);
		ma[i+1]=max(ma[i], sum);
	}
	ans[0]-=mi[q];
	ans[n-1]+=ma[q];
	rep(i, n-1) {
		ll x=T[i+1]-T[i];
		int p=0, k=q;
		while(p<k) {
			int sr=(p+k+1)/2;
			if(ma[sr]-mi[sr]<=x) p=sr; else k=sr-1;
		}
		ans[i]+=ma[p];
		ans[i+1]-=mi[p];
		x-=ma[p]-mi[p];
		if(p<q) {
			if(W[p]>=0) ans[i]+=x;
			else ans[i+1]+=x;
		}
	}
	rep(i, n) cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 26 ms 7104 KB Output is correct
21 Correct 28 ms 6900 KB Output is correct
22 Correct 25 ms 6660 KB Output is correct
23 Correct 23 ms 6596 KB Output is correct
24 Correct 30 ms 7072 KB Output is correct
25 Correct 93 ms 13372 KB Output is correct
26 Correct 96 ms 13376 KB Output is correct
27 Correct 101 ms 12996 KB Output is correct
28 Correct 96 ms 13188 KB Output is correct
29 Correct 96 ms 12728 KB Output is correct
30 Correct 94 ms 11972 KB Output is correct
31 Correct 58 ms 11568 KB Output is correct
32 Correct 56 ms 11632 KB Output is correct
33 Correct 9 ms 1604 KB Output is correct
34 Correct 93 ms 13720 KB Output is correct
35 Correct 93 ms 13124 KB Output is correct
36 Correct 97 ms 13544 KB Output is correct
37 Correct 102 ms 13176 KB Output is correct
38 Correct 96 ms 13004 KB Output is correct
39 Correct 90 ms 13156 KB Output is correct
40 Correct 69 ms 13124 KB Output is correct
41 Correct 35 ms 7636 KB Output is correct
42 Correct 54 ms 11648 KB Output is correct
43 Correct 75 ms 14916 KB Output is correct
44 Correct 28 ms 7544 KB Output is correct
45 Correct 58 ms 13120 KB Output is correct
46 Correct 73 ms 15108 KB Output is correct
47 Correct 79 ms 15288 KB Output is correct
48 Correct 87 ms 15324 KB Output is correct