Submission #1028656

# Submission time Handle Problem Language Result Execution time Memory
1028656 2024-07-20T06:45:07 Z JahonaliX Distributing Candies (IOI21_candies) C++17
0 / 100
66 ms 10264 KB
#include <bits/stdc++.h>

using namespace std;

vector<int>  distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size(), q = v.size();
    vector<int> a(n);
//    if (n <= 2000 && q <= 2000) {
//        for (int i = 0; i < q; ++i) for (int j = l[i]; j <= r[i]; ++j) a[j] = max(0, min(c[j], a[j] + v[i]));
//    }
//    else {
//        bool ok = true;
//        for (int i : v) ok &= i >= 0;
//        if (ok) {
            for (int i = 0; i < q; ++i) {
                a[l[i]] += v[i];
                if (r[i] + 1 < n) a[r[i] + 1] -= v[i];
            }
            for (int i = 1; i < n; ++i) a[i] += a[i - 1];
            for (int i = 0; i < n; ++i) a[i] = min(a[i], c[i]);
//        }
//        else {
//
//        }
//    }
    return a;
}

//int main() {
//    int n, q;
//    cin >> n >> q;
//    vector<int> c(n), l(q), r(q), v(q), a;
//    for (int &i : c) cin >> i;
//    for (int &i : l) cin >> i;
//    for (int &i : r) cin >> i;
//    for (int &i : v) cin >> i;
//    a = distribute_candies(c, l, r, v);
//    for (int i : a) cout << i << ' ';
//}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 10264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -