Submission #936637

# Submission time Handle Problem Language Result Execution time Memory
936637 2024-03-02T12:30:25 Z koukirocks Snowball (JOI21_ho_t2) C++17
100 / 100
74 ms 15444 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=2e5+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;

ll n,q;
ll pos[MAX];
pll dis[MAX];
pll rg[MAX];

int main() {
	speed;
	cin>>n>>q;
	for (int i=0;i<n;i++) {
		cin>>pos[i];
		rg[i]={-1,-1};
		if (i!=0) dis[i-1]={pos[i]-pos[i-1],i-1};
	}
	sort(dis,dis+n-1);
	ll L=0,R=0;
	ll now=0;
	ll id=0;
	while (q--) {
		ll k;
		cin>>k;
		now+=k;
		if (now>R) {
			R=now;
			while (id<n-1 and dis[id].first<R-L) {
//				cout<<dis[id].first<<" "<<dis[id].second<<" id\n";
				rg[dis[id].second].second=pos[dis[id].second+1]+L;
				rg[dis[id].second+1].first=pos[dis[id].second+1]+L;
				id++;
			}
		} else if (now<L) {
			L=now;
			while (id<n-1 and dis[id].first<R-L) {
				rg[dis[id].second+1].first=pos[dis[id].second]+R;
				rg[dis[id].second].second=pos[dis[id].second]+R;
				id++;
			}
		}
//		cout<<L<<" "<<R<<"\n";
	}
	for (int i=0;i<n;i++) {
//		cout<<rg[i].first<<" "<<rg[i].second<<"\n";
		if (rg[i].first==-1) rg[i].first=pos[i]+L;
		if (rg[i].second==-1) rg[i].second=pos[i]+R;
		cout<<rg[i].second-rg[i].first<<"\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2 ms 4444 KB Output is correct
20 Correct 17 ms 4444 KB Output is correct
21 Correct 16 ms 4440 KB Output is correct
22 Correct 16 ms 4444 KB Output is correct
23 Correct 15 ms 4440 KB Output is correct
24 Correct 18 ms 7004 KB Output is correct
25 Correct 67 ms 12232 KB Output is correct
26 Correct 61 ms 13396 KB Output is correct
27 Correct 61 ms 13120 KB Output is correct
28 Correct 58 ms 13136 KB Output is correct
29 Correct 60 ms 12604 KB Output is correct
30 Correct 66 ms 12116 KB Output is correct
31 Correct 55 ms 11632 KB Output is correct
32 Correct 40 ms 11604 KB Output is correct
33 Correct 7 ms 7256 KB Output is correct
34 Correct 63 ms 13880 KB Output is correct
35 Correct 74 ms 13140 KB Output is correct
36 Correct 59 ms 13372 KB Output is correct
37 Correct 58 ms 13244 KB Output is correct
38 Correct 61 ms 13140 KB Output is correct
39 Correct 61 ms 13140 KB Output is correct
40 Correct 61 ms 13136 KB Output is correct
41 Correct 20 ms 5236 KB Output is correct
42 Correct 50 ms 11764 KB Output is correct
43 Correct 55 ms 15184 KB Output is correct
44 Correct 22 ms 6972 KB Output is correct
45 Correct 55 ms 13136 KB Output is correct
46 Correct 56 ms 15172 KB Output is correct
47 Correct 57 ms 15252 KB Output is correct
48 Correct 56 ms 15444 KB Output is correct