# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
751644 |
2023-06-01T05:20:03 Z |
Kihihihi |
Snowball (JOI21_ho_t2) |
C++17 |
|
179 ms |
24720 KB |
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <ctime>
#include <chrono>
#include <cstdio>
#include <random>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <queue>
#include <bitset>
#include <list>
#include <fstream>
#include <functional>
#include <complex>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
short skip_cin = 0;
const long long INF = 1e18, MOD = 1e9 + 7, MOD2 = 998244353, LOG = 18;
const long double EPS = 1e-9, PI = acos(-1);
void solve()
{
long long n, q;
vector<long long> v;
cin >> n >> q;
v.resize(n + 2);
v[0] = -INF;
v[n + 1] = INF;
for (long long i = 1; i < n + 1; i++)
{
cin >> v[i];
}
n += 2;
long long l = 0, r = 0, cur = 0;
vector<long long> qr;
while (q--)
{
long long x;
cin >> x;
cur += x;
if (cur < l)
{
qr.push_back(cur - l);
l = cur;
}
else if (r < cur)
{
qr.push_back(cur - r);
r = cur;
}
}
q = qr.size();
set<pair<long long, long long>> sg;
for (long long i = 0; i < n - 1; i++)
{
sg.insert({ v[i + 1] - v[i], i });
}
long long suml = 0, sumr = 0;
vector<long long> ans(n + 2);
for (auto& i : qr)
{
while (sg.size() && sg.begin()->first <= suml + sumr + abs(i))
{
auto [len, idx] = *sg.begin();
sg.erase(sg.begin());
ans[idx] += sumr;
ans[idx + 1] += suml;
long long rest = len - suml - sumr;
if (i > 0)
{
ans[idx] += rest;
}
else
{
ans[idx + 1] += rest;
}
}
if (i > 0)
{
sumr += i;
}
else
{
suml += -i;
}
}
for (auto& [len, idx] : sg)
{
ans[idx] += sumr;
ans[idx + 1] += suml;
}
for (long long i = 1; i < n - 1; i++)
{
cout << ans[i] << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
srand(time(NULL));
int tst = 1;
//cin >> tst;
while (tst--)
{
solve();
}
return 0;
}
/*
<3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⠖⠚⢉⣩⣭⡭⠛⠓⠲⠦⣄⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⡴⠋⠁⠀⠀⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⢦⡀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡴⠃⢀⡴⢳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀
⠀⠀⠀⠀⡾⠁⣠⠋⠀⠈⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⠀⠀
⠀⠀⠀⣸⠁⢰⠃⠀⠀⠀⠈⢣⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⠀
⠀⠀⠀⡇⠀⡾⡀⠀⠀⠀⠀⣀⣹⣆⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠀
⠀⠀⢸⠃⢀⣇⡈⠀⠀⠀⠀⠀⠀⢀⡑⢄⡀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
⠀⠀⢸⠀⢻⡟⡻⢶⡆⠀⠀⠀⠀⡼⠟⡳⢿⣦⡑⢄⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
⠀⠀⣸⠀⢸⠃⡇⢀⠇⠀⠀⠀⠀⠀⡼⠀⠀⠈⣿⡗⠂⠀⠀⠀⠀⠀⠀⠀⢸⠁
⠀⠀⡏⠀⣼⠀⢳⠊⠀⠀⠀⠀⠀⠀⠱⣀⣀⠔⣸⠁⠀⠀⠀⠀⠀⠀⠀⢠⡟⠀
⠀⠀⡇⢀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠃⠀
⠀⢸⠃⠘⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠁⠀⠀⢀⠀⠀⠀⠀⠀⣾⠀⠀
⠀⣸⠀⠀⠹⡄⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⠸⠀⠀⠀⠀⠀⡇⠀⠀
⠀⡏⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⢀⣠⢶⡇⠀⠀⢰⡀⠀⠀⠀⠀⠀⡇⠀⠀
⢰⠇⡄⠀⠀⠀⡿⢣⣀⣀⣀⡤⠴⡞⠉⠀⢸⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⣧⠀⠀
⣸⠀⡇⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⢹⠀⠀⢸⠀⠀⢀⣿⠇⠀⠀⠀⠁⠀⢸⠀⠀
⣿⠀⡇⠀⠀⠀⠀⠀⢀⡤⠤⠶⠶⠾⠤⠄⢸⠀⡀⠸⣿⣀⠀⠀⠀⠀⠀⠈⣇⠀
⡇⠀⡇⠀⠀⡀⠀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠸⡌⣵⡀⢳⡇⠀⠀⠀⠀⠀⠀⢹⡀
⡇⠀⠇⠀⠀⡇⡸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠮⢧⣀⣻⢂⠀⠀⠀⠀⠀⠀⢧
⣇⠀⢠⠀⠀⢳⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡎⣆⠀⠀⠀⠀⠀⠘
⢻⠀⠈⠰⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠘⢮⣧⡀⠀⠀⠀⠀
⠸⡆⠀⠀⠇⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠆⠀⠀⠀⠀⠀⠀⠀⠙⠳⣄⡀⢢⡀
<3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3 <3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
0 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 |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
29 ms |
4164 KB |
Output is correct |
21 |
Correct |
28 ms |
4024 KB |
Output is correct |
22 |
Correct |
26 ms |
3848 KB |
Output is correct |
23 |
Correct |
23 ms |
3760 KB |
Output is correct |
24 |
Correct |
33 ms |
5184 KB |
Output is correct |
25 |
Correct |
166 ms |
22856 KB |
Output is correct |
26 |
Correct |
152 ms |
22768 KB |
Output is correct |
27 |
Correct |
157 ms |
22396 KB |
Output is correct |
28 |
Correct |
147 ms |
22352 KB |
Output is correct |
29 |
Correct |
141 ms |
21320 KB |
Output is correct |
30 |
Correct |
127 ms |
19928 KB |
Output is correct |
31 |
Correct |
88 ms |
19352 KB |
Output is correct |
32 |
Correct |
94 ms |
19548 KB |
Output is correct |
33 |
Correct |
12 ms |
2512 KB |
Output is correct |
34 |
Correct |
158 ms |
21580 KB |
Output is correct |
35 |
Correct |
139 ms |
21196 KB |
Output is correct |
36 |
Correct |
158 ms |
22724 KB |
Output is correct |
37 |
Correct |
151 ms |
22088 KB |
Output is correct |
38 |
Correct |
159 ms |
22212 KB |
Output is correct |
39 |
Correct |
134 ms |
22408 KB |
Output is correct |
40 |
Correct |
117 ms |
22468 KB |
Output is correct |
41 |
Correct |
32 ms |
4652 KB |
Output is correct |
42 |
Correct |
156 ms |
19404 KB |
Output is correct |
43 |
Correct |
123 ms |
24404 KB |
Output is correct |
44 |
Correct |
38 ms |
4544 KB |
Output is correct |
45 |
Correct |
179 ms |
22444 KB |
Output is correct |
46 |
Correct |
122 ms |
24464 KB |
Output is correct |
47 |
Correct |
125 ms |
23628 KB |
Output is correct |
48 |
Correct |
119 ms |
24720 KB |
Output is correct |