# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
936692 | 2024-03-02T14:21:36 Z | anton | Snowball (JOI21_ho_t2) | C++17 | 1061 ms | 14520 KB |
#include<bits/stdc++.h> #include <vector> using namespace std; #define int long long #define pii pair<int, int> vector<int> p; vector<pii> r; vector<pii> l; vector<int> res; vector<int> x; vector<int> w; pii last_before(int time, vector<pii>& v){ int r= 0; for(int step = (1LL<<20LL); step>=1; step/=2){ int next= r+step; if(next<v.size() && v[next].first<=time){ r = next; } } return v[r]; } int find_intersection_moment(int dist){ int time= 0; for(int step = (1LL<<20LL); step>=1; step/=2){ int next= time+step; pii rh = last_before(next, r); pii lh =last_before(next, l); if(dist-rh.second+lh.second>0){ time=next; } } //cout<<"majoration "<<dist<<" "<<time<<endl; if(time>1e6){ return -1; } return time+1; } void add_major(int i, int j){ int t= find_intersection_moment(x[j]-x[i]); if(t==-1){ res[i]+=r.back().second; res[j]-=l.back().second; //cout<<i<<" "<<j<<endl; return; } int pos1 = last_before(t-1, r).second; res[i] += pos1; int pos2= last_before(t-1, l).second; res[j] -= pos2; //cout<<pos1<<" "<<pos2<<endl; //cout<<w[t-1]<<endl; if(w[t-1]>0){ res[i] += ((x[j]-x[i])+pos2-pos1); //cout<<((x[j]-x[i])+pos2-pos1)<<" i "<<endl; } else{ res[j] += ((x[j]-x[i])+pos2-pos1); //cout<<((x[j]-x[i])+pos2-pos1)<<" j "<<endl; } } signed main(){ int n, q; cin>>n>>q; x.push_back(-1e18); for(int i = 0; i<n; i++){ int v; cin>>v; x.push_back(v); } x.push_back(1e18); p.push_back(0); w.resize(q); for(int i = 0; i<q; i++){ cin>>w[i]; p.push_back(p.back()+w[i]); } int rmost= -1; for(int i = 0; i<=q; i++){ if(p[i]>rmost){ rmost = p[i]; r.push_back({i, p[i]}); } } int lmost= 1; for(int i = 0; i<=q; i++){ if(p[i]<lmost){ lmost = p[i]; l.push_back({i, p[i]}); } } res.resize(n+2); for(int i = 0; i<=n; i++){ add_major(i, i+1); //cout<<"added 1"<<endl; } for(int i = 1; i<=n; i++){ cout<<res[i]<<endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 504 KB | Output is correct |
4 | Correct | 6 ms | 604 KB | Output is correct |
5 | Correct | 6 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 492 KB | Output is correct |
7 | Correct | 6 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 580 KB | Output is correct |
9 | Correct | 8 ms | 604 KB | Output is correct |
10 | Correct | 5 ms | 348 KB | Output is correct |
11 | Correct | 5 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 6 ms | 604 KB | Output is correct |
16 | Correct | 6 ms | 604 KB | Output is correct |
17 | Correct | 8 ms | 604 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 5 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 504 KB | Output is correct |
4 | Correct | 6 ms | 604 KB | Output is correct |
5 | Correct | 6 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 492 KB | Output is correct |
7 | Correct | 6 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 580 KB | Output is correct |
9 | Correct | 8 ms | 604 KB | Output is correct |
10 | Correct | 5 ms | 348 KB | Output is correct |
11 | Correct | 5 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 6 ms | 604 KB | Output is correct |
16 | Correct | 6 ms | 604 KB | Output is correct |
17 | Correct | 8 ms | 604 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 5 ms | 348 KB | Output is correct |
20 | Correct | 66 ms | 9276 KB | Output is correct |
21 | Correct | 69 ms | 9488 KB | Output is correct |
22 | Correct | 61 ms | 9028 KB | Output is correct |
23 | Correct | 71 ms | 9100 KB | Output is correct |
24 | Correct | 146 ms | 9156 KB | Output is correct |
25 | Correct | 1006 ms | 13772 KB | Output is correct |
26 | Correct | 1061 ms | 13492 KB | Output is correct |
27 | Correct | 984 ms | 13116 KB | Output is correct |
28 | Correct | 1012 ms | 12740 KB | Output is correct |
29 | Correct | 909 ms | 12096 KB | Output is correct |
30 | Correct | 534 ms | 9344 KB | Output is correct |
31 | Correct | 527 ms | 9024 KB | Output is correct |
32 | Correct | 506 ms | 9016 KB | Output is correct |
33 | Correct | 82 ms | 1864 KB | Output is correct |
34 | Correct | 599 ms | 10844 KB | Output is correct |
35 | Correct | 711 ms | 10556 KB | Output is correct |
36 | Correct | 991 ms | 13244 KB | Output is correct |
37 | Correct | 946 ms | 12476 KB | Output is correct |
38 | Correct | 996 ms | 13060 KB | Output is correct |
39 | Correct | 978 ms | 12880 KB | Output is correct |
40 | Correct | 921 ms | 13004 KB | Output is correct |
41 | Correct | 82 ms | 9428 KB | Output is correct |
42 | Correct | 472 ms | 9128 KB | Output is correct |
43 | Correct | 969 ms | 14448 KB | Output is correct |
44 | Correct | 75 ms | 9520 KB | Output is correct |
45 | Correct | 550 ms | 13268 KB | Output is correct |
46 | Correct | 939 ms | 14388 KB | Output is correct |
47 | Correct | 745 ms | 12568 KB | Output is correct |
48 | Correct | 787 ms | 14520 KB | Output is correct |