///
/// Let the voice of love take you higher!
///
#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(int x = (l); x < (r); ++x)
#define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
typedef std::pair<ll ,ll > pll;
using namespace std;
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx")
typedef vector<int> vec;
const int N = 200'010;
int a[N], c[N], l[N], r[N], v[N];
int n, q;
vec distribute_candies(vec cc, vec ll, vec rr, vec vv)
{
n = cc.size();
q = ll.size();
Loop(i,0,n) c[i] = cc[i];
Loop(i,0,q) l[i] = ll[i], r[i] = rr[i], v[i] = vv[i];
Loop(i,0,q)
{
int v = ::v[i], l = ::l[i], r = ::r[i]+1;
if(i&1)
{
if(v <= 0)
Loop(j,l,r)
a[j] = a[j]+v<0?0:a[j]+v;
else
Loop(j,l,r)
a[j] = a[j]+v>c[j]?c[j]:a[j]+v;
}
else
{
if(v <= 0)
LoopR(j,l,r)
a[j] = a[j]+v<0?0:a[j]+v;
else
LoopR(j,l,r)
a[j] = a[j]+v>c[j]?c[j]:a[j]+v;
}
}
vec ans(n);
Loop(i,0,n) ans[i] = a[i];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3456 ms |
11244 KB |
Output is correct |
2 |
Correct |
3355 ms |
15328 KB |
Output is correct |
3 |
Correct |
3443 ms |
15164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
97 ms |
10332 KB |
Output is correct |
3 |
Correct |
89 ms |
7588 KB |
Output is correct |
4 |
Correct |
3276 ms |
17180 KB |
Output is correct |
5 |
Correct |
3183 ms |
17556 KB |
Output is correct |
6 |
Correct |
3144 ms |
17948 KB |
Output is correct |
7 |
Correct |
3076 ms |
17284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
129 ms |
9932 KB |
Output is correct |
4 |
Correct |
134 ms |
5604 KB |
Output is correct |
5 |
Execution timed out |
5043 ms |
13892 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
464 KB |
Output is correct |
6 |
Correct |
3456 ms |
11244 KB |
Output is correct |
7 |
Correct |
3355 ms |
15328 KB |
Output is correct |
8 |
Correct |
3443 ms |
15164 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
97 ms |
10332 KB |
Output is correct |
11 |
Correct |
89 ms |
7588 KB |
Output is correct |
12 |
Correct |
3276 ms |
17180 KB |
Output is correct |
13 |
Correct |
3183 ms |
17556 KB |
Output is correct |
14 |
Correct |
3144 ms |
17948 KB |
Output is correct |
15 |
Correct |
3076 ms |
17284 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
129 ms |
9932 KB |
Output is correct |
19 |
Correct |
134 ms |
5604 KB |
Output is correct |
20 |
Execution timed out |
5043 ms |
13892 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |