Submission #553803

# Submission time Handle Problem Language Result Execution time Memory
553803 2022-04-27T06:29:05 Z drdilyor Distributing Candies (IOI21_candies) C++17
0 / 100
100 ms 8036 KB
#include "candies.h"

#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
using namespace std;

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size(), m = l.size();

    int allInc = 1;
    for (int i = 0; i < m; i++) {
        if (v[i] < 0) allInc = 0;
    }
    std::vector<int> s(n);

    if (allInc) {

        vi diff(n + 1);
        for (int i = 0; i < m; i++) {
            diff[l[i]] += v[i];
            diff[r[i]+1] -= v[i];
        }
        for (int i = 0, sum = 0; i < n; i++) {
            sum += diff[i];
            s[i] = max(sum, c[i]);
        }
    } else {
        for (int i = 0; i < m; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                s[i] = max(0, min(c[i], s[i] + v[i]));
            }
        }
    }
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 8036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -