Submission #1058415

# Submission time Handle Problem Language Result Execution time Memory
1058415 2024-08-14T09:54:38 Z vjudge1 Distributing Candies (IOI21_candies) C++17
11 / 100
65 ms 12980 KB
#include "candies.h"

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

vi distribute_candies(vi c, vi l, vi r, vi v) {
    int n = c.size(), q = l.size();
    bool all_poz = true;
    for(auto it : v)
        if(it < 0) all_poz = false;
    if(n <= 2000 && q <= 2000) {
        vi A(n, 0);
        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;
    }
    if(all_poz) {
        vll S(n, 0);
        for(int i = 0; i < q; ++i) {
            S[l[i]] += v[i];
            if(r[i] + 1 < n) S[r[i] + 1] -= v[i];
        }
        for(int i = 1; i < n; ++i) {
            S[i] = S[i] + S[i - 1];
        }
        vi Re(n, 0);
        for(int i = 0; i < n; ++i) {
            Re[i] = min(S[i], (ll)c[i]);
        }
        return Re;
    }
    return vi();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 9044 KB Output is correct
2 Correct 65 ms 12980 KB Output is correct
3 Correct 53 ms 12708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 26 ms 5100 KB Output isn't correct
3 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 Incorrect 50 ms 5100 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 57 ms 9044 KB Output is correct
7 Correct 65 ms 12980 KB Output is correct
8 Correct 53 ms 12708 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 26 ms 5100 KB Output isn't correct
11 Halted 0 ms 0 KB -