#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define mod 998244353
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
using namespace std;
const int maxn = 200005;
int n, q;
vi a(maxn);
vi brute_force(vi c, vi l, vi r, vi v) {
for (int i = 0; i < q; i++) {
for (int j = l[i] - 1; j < r[i]; j++) {
if (v[i] > 0) a[i] = min(c[i], a[i] + v[i]);
else a[i] = max(0, a[i] + v[i]);
}
}
return a;
}
vi distribute_candies(vi c, vi l, vi r, vi v) {
n = (int) c.size();
q = (int) l.size();
a.resize(n);
if (n <= 1000 && q <= 1000) {
return brute_force(c, l, r, v);
}
}
Compilation message
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
36 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5048 ms |
10444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1100 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |