# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
624317 |
2022-08-07T19:06:15 Z |
Ronin13 |
Snowball (JOI21_ho_t2) |
C++14 |
|
1 ms |
340 KB |
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int NMAX = 200005;
const ll linf = 1e18 + 1;
ll mn[NMAX], mx[NMAX];
int main(){
int n, q; cin >> n >> q;
ll a[n + 2];
a[0] = -linf;
a[n + 1] = linf;
for(int i =1; i <= n; i++) cin >> a[i];
ll pref[q + 1];
mn[0] = linf;
mx[0] = -linf;
pref[0] = 0;
for(int i = 1; i <= q; i++){
ll x; cin >> x;
pref[i] = pref[i - 1] + x;
mx[i] = max(mx[i - 1], pref[i]);
mn[i] = min(mn[i - 1], pref[i]);
//cout << mx[i] << ' ' << mn[i] << "\n";
}
ll ans[n + 2];
for(int i = 0; i <= n + 1; i++) ans[i] = 0;
for(int i = 1; i <= n + 1; i++){
ll l = 0, r = a[i] - a[i - 1];
while(l + 1 < r){
ll mid = (l + r) / 2;
ll l1 = 0, r1 = q + 1;
while(l1 + 1 < r1){
ll mid1 = l1 + r1; mid1 /= 2;
if(mn[mid1] <= -mid) r1 = mid1;
else l1 = mid1;
}
// cout << 1;
if(r1 == q + 1){
r = mid;
continue;
}
if(mx[r1] < a[i] - a[i - 1] - mid) l = mid;
else {r = mid;}
}
//cout << l << "\n";
if(mx[q] < a[i] - a[i - 1] - l) ans[i - 1] += mx[q];
else ans[i - 1] += a[i] - a[i - 1] - l - 1;
ans[i] += l;
}
for(int i = 1; i <= n; i++){
cout << ++ans[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |