# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
814639 |
2023-08-08T08:41:57 Z |
Cookie |
Snowball (JOI21_ho_t2) |
C++14 |
|
2500 ms |
4736 KB |
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("FEEDING.INP");
ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
// int y[4] = {0, 0, 1, -1};
const ll mod = 1e15 + 7, inf = 1e16;
const int mxn = 1e5 + 5;
int n, q;
ll x[mxn + 1], ans[mxn + 1];
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> q;
for(int i = 1; i <= n; i++)cin >> x[i];
vt<pll>seg;
for(int i = 1; i < n; i++){
seg.pb(make_pair(x[i + 1] - x[i], i));
}
sort(seg.begin(), seg.end());
ll mx = 0, mn = 0, p = 0;
int r = 0;
for(int i = 1; i <= q; i++){
ll w; cin >> w;
p += w;
mx = max(mx, p); mn = min(mn, p);
while(r < sz(seg) && seg[r].first <= mx + abs(mn)){
int id = seg[r].second;
if(w < 0){
ans[id] += mx; ans[id + 1] += (seg[r].first - mx);
}else{
ans[id + 1] += abs(mn); ans[id] += (seg[r].first - abs(mn));
}
r++;
}
}
for(int i = r; i < sz(seg); i++){
int id = seg[i].second;
ans[id] += mx; ans[id + 1] += abs(mn);
}
ans[n] += mx; ans[1] += abs(mn);
for(int i = 1; i <= n; i++)cout << ans[i] << "\n";
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
476 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
472 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
476 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
472 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
28 ms |
2452 KB |
Output is correct |
21 |
Correct |
18 ms |
2220 KB |
Output is correct |
22 |
Correct |
20 ms |
2000 KB |
Output is correct |
23 |
Correct |
16 ms |
2000 KB |
Output is correct |
24 |
Correct |
20 ms |
2876 KB |
Output is correct |
25 |
Execution timed out |
2567 ms |
4736 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |