# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
523532 |
2022-02-07T18:08:36 Z |
placik |
Snowball (JOI21_ho_t2) |
C++17 |
|
115 ms |
16876 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define st first
#define nd second
#define pb push_back
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define all(a) a.begin(),a.end()
#define sz(x) (ll)(x).size()
const int mxN = 2e5+7;
ll x[mxN],odp[mxN];
struct poz{
ll lewo,prawo;
ll suma;
int kogo_ruch; //0 brak, 1 lewo, 2 prawo
};
poz t[mxN];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,q,w; cin >> n >> q;
rep(i,1,n) cin >> x[i];
ll akt=0,mL=0,mP=0;
rep(i,1,q){
cin >> w;
if(w > 0) t[i-1].kogo_ruch = 2;
if(w < 0) t[i-1].kogo_ruch = 1;
akt += w;
mL = min(akt,mL);
mP = max(akt,mP);
t[i] = {mL,mP,mP-mL,0};
}
odp[1] -= mL;
odp[n] += mP;
rep(i,2,n){
ll odl = x[i]-x[i-1];
int p=0,k=q;
while(p < k){
int m = (p+k+1)/2;
if(t[m].suma <= odl) p = m;
else k = m-1;
}
odp[i] -= t[p].lewo;
odp[i-1] += t[p].prawo;
odl -= t[p].prawo;
odl += t[p].lewo;
//cout << i << " " << odl << "\n";
if(t[p].kogo_ruch == 1) odp[i] += odl;
if(t[p].kogo_ruch == 2) odp[i-1] += odl;
}
//rep(i,0,q) cout << i << " " << t[i].lewo << " " << t[i].prawo << " " << t[i].suma << " " << t[i].kogo_ruch << "\n";
rep(i,1,n) cout << odp[i] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
368 KB |
Output is correct |
9 |
Correct |
2 ms |
352 KB |
Output is correct |
10 |
Correct |
2 ms |
460 KB |
Output is correct |
11 |
Correct |
2 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 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 |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
368 KB |
Output is correct |
9 |
Correct |
2 ms |
352 KB |
Output is correct |
10 |
Correct |
2 ms |
460 KB |
Output is correct |
11 |
Correct |
2 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 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 |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
464 KB |
Output is correct |
20 |
Correct |
28 ms |
8676 KB |
Output is correct |
21 |
Correct |
26 ms |
8388 KB |
Output is correct |
22 |
Correct |
26 ms |
8232 KB |
Output is correct |
23 |
Correct |
26 ms |
8184 KB |
Output is correct |
24 |
Correct |
37 ms |
8612 KB |
Output is correct |
25 |
Correct |
98 ms |
14912 KB |
Output is correct |
26 |
Correct |
101 ms |
14896 KB |
Output is correct |
27 |
Correct |
108 ms |
14660 KB |
Output is correct |
28 |
Correct |
101 ms |
14692 KB |
Output is correct |
29 |
Correct |
115 ms |
14152 KB |
Output is correct |
30 |
Correct |
90 ms |
13548 KB |
Output is correct |
31 |
Correct |
63 ms |
12964 KB |
Output is correct |
32 |
Correct |
56 ms |
13240 KB |
Output is correct |
33 |
Correct |
11 ms |
1760 KB |
Output is correct |
34 |
Correct |
106 ms |
15344 KB |
Output is correct |
35 |
Correct |
108 ms |
14656 KB |
Output is correct |
36 |
Correct |
112 ms |
14916 KB |
Output is correct |
37 |
Correct |
110 ms |
14760 KB |
Output is correct |
38 |
Correct |
94 ms |
14532 KB |
Output is correct |
39 |
Correct |
91 ms |
14752 KB |
Output is correct |
40 |
Correct |
68 ms |
14788 KB |
Output is correct |
41 |
Correct |
28 ms |
9180 KB |
Output is correct |
42 |
Correct |
54 ms |
13188 KB |
Output is correct |
43 |
Correct |
80 ms |
16508 KB |
Output is correct |
44 |
Correct |
29 ms |
9068 KB |
Output is correct |
45 |
Correct |
68 ms |
14784 KB |
Output is correct |
46 |
Correct |
86 ms |
16564 KB |
Output is correct |
47 |
Correct |
82 ms |
16836 KB |
Output is correct |
48 |
Correct |
79 ms |
16876 KB |
Output is correct |