# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059494 | 2024-08-15T03:40:54 Z | pcc | Distributing Candies (IOI21_candies) | C++17 | 73 ms | 13652 KB |
#include "candies.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second #define ll long long int N,Q; 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(); if(N*Q<=1e7){ vector<int> ans(N,0); for(int i = 0;i<Q;i++){ for(int j = l[i];j<=r[i];j++){ if(v[i]>0)ans[j] = min(ans[j]+v[i],c[j]); else ans[j] = max(ans[j]+v[i],0); } } return ans; } else if(*min_element(v.begin(),v.end())>=0){ vector<ll> dif(N+1,0); for(int i = 0;i<Q;i++){ dif[l[i]] += v[i]; dif[r[i]+1] -= v[i]; } for(int i = 1;i<dif.size();i++)dif[i] += dif[i-1]; vector<int> ans(N); for(int i = 0;i<N;i++)ans[i] = min(1ll*c[i],dif[i]); return ans; } assert(false); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 13652 KB | Output is correct |
2 | Correct | 70 ms | 13032 KB | Output is correct |
3 | Correct | 63 ms | 12884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Runtime error | 40 ms | 13132 KB | Execution killed with signal 6 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Runtime error | 37 ms | 12640 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 73 ms | 13652 KB | Output is correct |
7 | Correct | 70 ms | 13032 KB | Output is correct |
8 | Correct | 63 ms | 12884 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Runtime error | 40 ms | 13132 KB | Execution killed with signal 6 |
11 | Halted | 0 ms | 0 KB | - |