Submission #1063469

# Submission time Handle Problem Language Result Execution time Memory
1063469 2024-08-17T19:06:05 Z deera Distributing Candies (IOI21_candies) C++17
11 / 100
74 ms 13652 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();

    bool non_neg = true;
    for (int val: v) if (val < 0) {
        non_neg = false;
        break;
    }

    if (non_neg == true) {
        vector<long long> diff(n + 1, 0);

        for (int i = 0; i < q; i++) {
            diff[l[i]] += v[i];
            diff[r[i] + 1] -= v[i];
        }

        for (int i = 1; i < n; i++) {
            diff[i] += diff[i - 1];
        }

        vector<int> res(n, 0);
        for (int i = 0; i < n; i++) {
            res[i] = min((long long)c[i], diff[i]);
        }

        return res;
    }

    if (n <= 2000 && q <= 2000) {
        vector<int> res(n, 0);
        for (int i = 0; i < q; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                res[j] = max(min(res[j] + v[i], c[j]), (int)0);
            }
        }
        return res;
    }

    return vector<int>();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 13652 KB Output is correct
2 Correct 68 ms 12884 KB Output is correct
3 Correct 61 ms 12880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 34 ms 7904 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 32 ms 7764 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 KB Output is correct
6 Correct 74 ms 13652 KB Output is correct
7 Correct 68 ms 12884 KB Output is correct
8 Correct 61 ms 12880 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 34 ms 7904 KB Output isn't correct
11 Halted 0 ms 0 KB -