Submission #1061337

#TimeUsernameProblemLanguageResultExecution timeMemory
1061337TheQuantiXDistributing Candies (IOI21_candies)C++17
11 / 100
343 ms13800 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; ll n, m, q, k, x, y, a, b, c; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { n = c.size(); q = v.size(); vector<int> ans(n); if (n <= 2000) { for (int i = 0; i < q; i++) { for (int j = l[i]; j <= r[i]; j++) { ans[j] += v[i]; ans[j] = max(0, ans[j]); ans[j] = min(c[j], ans[j]); } } return ans; } if (*min_element(v.begin(), v.end()) >= 0) { vector<ll> ev(n + 1); for (int i = 0; i < q; i++) { ev[l[i]] += v[i]; ev[r[i] + 1] -= v[i]; } ll cnt = 0; for (int i = 0; i < n; i++) { cnt += ev[i]; ans[i] = min((ll)c[i], cnt); } return ans; } }

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:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
#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...