This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]; j <= r[i]; j++) {
if (v[i] > 0) a[j] = min(c[j], a[j] + v[i]);
else a[j] = max(0, a[j] + 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 (stderr)
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 | }
| ^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |