Submission #435747

#TimeUsernameProblemLanguageResultExecution timeMemory
435747illyakrDistributing Candies (IOI21_candies)C++17
11 / 100
128 ms9708 KiB
#include <bits/stdc++.h> #include "candies.h" using namespace std; #define ll long long vector<int> res; int n, q; bool scbl = true; ll _res[201010]; std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { n = c.size(); q = v.size(); res.resize(n, 0); for (int i = 0; i < q; i++) if (v[i] < 0){scbl = false;break;} if (n * q <= 100000000) { for (int i = 0; i < q; i++) { for (int j = l[i]; j <= r[i]; j++) { res[j] += v[i]; if (res[j] < 0)res[j] = 0; else if (res[j] > c[j])res[j] = c[j]; } } return res; } if (scbl) { for (int i = 0; i < q; i++) { _res[l[i]] += v[i]; _res[r[i] + 1] -= v[i]; } for (int i = 1; i < n; i++) _res[i] += _res[i - 1]; for (int i = 0; i < n; i++) { _res[i] = min(_res[i], (ll)c[i]); res[i] = _res[i]; } return res; } } /** 3 10 15 13 2 0 2 20 0 1 -11 0 4 13 */

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