# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
697362 |
2023-02-09T12:51:33 Z |
micjan |
Snowball (JOI21_ho_t2) |
C++14 |
|
105 ms |
15440 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define st first
#define nd second
#define FOR(i,j,k) for(auto i = (j); i<(k); i++)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define BOOST ios_base::sync_with_stdio(0);cin.tie(0);
const int MN = 2e5+10;
const ll inf = 1e18+2;
ll maxi[MN], mini[MN];
ll poz[MN];
ll W[MN];
ll ans[MN];//jak dużo zjadła kulka
int main()
{
BOOST;
int n,q;
cin>>n>>q;
FOR(i,1,n+1) cin>>poz[i];
ll sum = 0;
FOR(i,1,q+1)
{
cin>>W[i];
sum+=W[i];
maxi[i] = max(maxi[i-1],sum);
mini[i] = min(mini[i-1],sum);
}
ans[1] += abs(mini[q]);//weźmie wszystko po lewej
ans[n] += maxi[q];//weźmie wszystko po prawej
FOR(i,2,n+1)//punkt spotkania i oraz i-1 kulki
{
int l = 0, p = q;
while(l<p)
{
int s = (l+p+1)>>1;
if(poz[i-1]+maxi[s] <= poz[i]+mini[s])
l = s;
else
p = s-1;
}
ans[i-1]+=maxi[l];
ans[i]+= -mini[l];
if(l<q)
ans[ W[l+1] < 0 ? i : i-1 ] += poz[i]+mini[l]-poz[i-1]-maxi[l];
}
FOR(i,1,n+1) cout<<ans[i]<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
396 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
412 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
368 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
396 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
412 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
368 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
27 ms |
7104 KB |
Output is correct |
21 |
Correct |
24 ms |
6860 KB |
Output is correct |
22 |
Correct |
26 ms |
6736 KB |
Output is correct |
23 |
Correct |
22 ms |
6628 KB |
Output is correct |
24 |
Correct |
27 ms |
7116 KB |
Output is correct |
25 |
Correct |
96 ms |
13400 KB |
Output is correct |
26 |
Correct |
101 ms |
13384 KB |
Output is correct |
27 |
Correct |
97 ms |
13036 KB |
Output is correct |
28 |
Correct |
95 ms |
13196 KB |
Output is correct |
29 |
Correct |
90 ms |
12620 KB |
Output is correct |
30 |
Correct |
88 ms |
12088 KB |
Output is correct |
31 |
Correct |
58 ms |
11408 KB |
Output is correct |
32 |
Correct |
58 ms |
11596 KB |
Output is correct |
33 |
Correct |
9 ms |
1748 KB |
Output is correct |
34 |
Correct |
105 ms |
13744 KB |
Output is correct |
35 |
Correct |
94 ms |
13400 KB |
Output is correct |
36 |
Correct |
97 ms |
13336 KB |
Output is correct |
37 |
Correct |
92 ms |
13104 KB |
Output is correct |
38 |
Correct |
91 ms |
13028 KB |
Output is correct |
39 |
Correct |
92 ms |
13388 KB |
Output is correct |
40 |
Correct |
67 ms |
13204 KB |
Output is correct |
41 |
Correct |
28 ms |
7792 KB |
Output is correct |
42 |
Correct |
51 ms |
11660 KB |
Output is correct |
43 |
Correct |
75 ms |
14924 KB |
Output is correct |
44 |
Correct |
29 ms |
7508 KB |
Output is correct |
45 |
Correct |
61 ms |
13132 KB |
Output is correct |
46 |
Correct |
77 ms |
15052 KB |
Output is correct |
47 |
Correct |
76 ms |
15316 KB |
Output is correct |
48 |
Correct |
81 ms |
15440 KB |
Output is correct |