Submission #1064242

#TimeUsernameProblemLanguageResultExecution timeMemory
1064242c2zi6Distributing Candies (IOI21_candies)C++17
3 / 100
54 ms14712 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "candies.h" struct QUERY { int l, r, v; }; typedef vector<QUERY> VQ; namespace TEST1 { VI solve(VI c, VQ qrs) { int n = c.size(); int q = qrs.size(); VI a(n); for (auto[l, r, v] : qrs) { replr(i, l, r) { a[i] += v; setmin(a[i], c[i]); setmax(a[i], 0); } } return a; } }; VI distribute_candies(VI c, VI l, VI r, VI v) { int n = c.size(); int q = l.size(); VQ qrs; rep(i, q) qrs.pb({l[i], r[i], v[i]}); if (n <= 2000 && q <= 2000) return TEST1::solve(c, qrs); return VI(); }

Compilation message (stderr)

candies.cpp: In function 'VI TEST1::solve(VI, VQ)':
candies.cpp:42:13: warning: unused variable 'q' [-Wunused-variable]
   42 |         int q = qrs.size();
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...