Submission #924859

# Submission time Handle Problem Language Result Execution time Memory
924859 2024-02-10T00:04:28 Z Programmer123 Distributing Candies (IOI21_candies) C++17
8 / 100
84 ms 12880 KB
#include "candies.h"

#include <bits/stdc++.h>

typedef std::vector<int> ivec;
#define int long long

ivec distribute_candies(ivec c, ivec l,
                        ivec r, ivec v) {
    int N = c.size();
    int Q = l.size();
    ivec ans(N);
    int diff[N + 1];
    for (int i = 0; i <= N; ++i) {
        diff[i] = 0;
    }
    for (int i = 0; i < Q; ++i) {
        diff[l[i]] += v[i];
        diff[r[i] + 1] -= v[i];
        assert(v[i] >= 0);
    }
    for (int i = 1; i <= N; ++i) {
        diff[i] += diff[i - 1];
        assert(diff[i] >= 0);
    }
    assert(diff[N] == 0);
    for (int i = 0; i < N; ++i) {
        ans[i] = std::min<int>(diff[i], c[i]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 84 ms 8860 KB Output is correct
2 Correct 79 ms 12880 KB Output is correct
3 Correct 80 ms 12836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -