# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052982 | 2024-08-11T07:11:18 Z | mychecksedad | Distributing Candies (IOI21_candies) | C++17 | 3555 ms | 2097152 KB |
#include "candies.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define all(x) x.begin(),x.end() #define vi vector<int> #define pii pair<int,int> #define ff first #define ss second const int N = 3e5+100; std::vector<int> distribute_candies(std::vector<int> cc, std::vector<int> l, std::vector<int> r, std::vector<int> v) { vector<ll> c(all(cc)); int n = c.size(); int q = l.size(); std::vector<int> s(n); vector<vector<int>> Q(n); for(int i = 0; i < q; ++i){ for(int j = l[i]; j <= r[i]; ++j){ Q[j].pb(v[i]); } } for(int i = 0; i < n; ++i){ if(Q[i].size() == 0) continue; ll sum = 0; int x = 0; for(int j = Q[i].size() - 1; j >= 0; --j){ // cout << Q[i][j] << ' '; ll v = Q[i][j]; if(v >= c[i]){ x = j; break; }else if(v <= -c[i]){ x = j; break; } if(sum + v <= -c[i]){ x = j; break; }else if(sum + v >= c[i]){ x = j; break; }else{ sum += v; } } sum = 0; for(int j = x; j < Q[i].size(); ++j){ sum += Q[i][j]; sum = max(0ll, min(sum, c[i])); } s[i] = sum; } return s; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 860 KB | Output is correct |
5 | Correct | 6 ms | 7340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2437 ms | 2097152 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1196 ms | 569464 KB | Output is correct |
3 | Correct | 1159 ms | 650664 KB | Output is correct |
4 | Runtime error | 2358 ms | 2097152 KB | Execution killed with signal 9 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 600 KB | Output is correct |
3 | Correct | 3555 ms | 1611920 KB | Output is correct |
4 | Correct | 2663 ms | 1616576 KB | Output is correct |
5 | Runtime error | 2513 ms | 2097152 KB | Execution killed with signal 9 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 860 KB | Output is correct |
5 | Correct | 6 ms | 7340 KB | Output is correct |
6 | Runtime error | 2437 ms | 2097152 KB | Execution killed with signal 9 |
7 | Halted | 0 ms | 0 KB | - |