Submission #796121

# Submission time Handle Problem Language Result Execution time Memory
796121 2023-07-28T06:38:40 Z t6twotwo Distributing Candies (IOI21_candies) C++17
11 / 100
94 ms 8872 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> distribute_candies(vector<int> C, vector<int> L, vector<int> R, vector<int> V) {
    for (int &x : R) {
        x++;
    }
    int N = C.size(), Q = L.size();
    if (N <= 2000 && Q <= 2000) {
        vector<int> A(N);
        for (int i = 0; i < Q; i++) {
            for (int j = L[i]; j < R[i]; j++) {
                A[j] += V[i];
                A[j] = max(A[j], 0);
                A[j] = min(A[j], C[j]);
            }
        }
        return A;
    }
    vector<ll> s(N + 1);
    for (int i = 0; i < Q; i++) {
        s[L[i]] += V[i];
        s[R[i]] -= V[i];
    }
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = min((ll)C[i], s[i]);
        s[i + 1] += s[i];
    }
    return A;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 8812 KB Output is correct
2 Correct 74 ms 8872 KB Output is correct
3 Correct 94 ms 8804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 40 ms 4968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 40 ms 4960 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 77 ms 8812 KB Output is correct
7 Correct 74 ms 8872 KB Output is correct
8 Correct 94 ms 8804 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 40 ms 4968 KB Output isn't correct
11 Halted 0 ms 0 KB -