Submission #435741

# Submission time Handle Problem Language Result Execution time Memory
435741 2021-06-23T16:23:54 Z illyakr Distributing Candies (IOI21_candies) C++17
3 / 100
125 ms 8116 KB
#include <bits/stdc++.h>
#include "candies.h"
using namespace std;

vector<int> res;
int n, q;
bool scbl = true;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    n = c.size(); q = v.size();
    res.resize(n, 0);
    for (int i = 0; i < q; i++)
        if (v[i] < 0){scbl = false;break;}

    if (n * q <= 100000000) {
        for (int i = 0; i < q; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                res[j] += v[i];
                if (res[j] < 0)res[j] = 0;
                else if (res[j] > c[j])res[j] = c[j];
            }
        }
        return res;
    }
    if (scbl) {
        for (int i = 0; i < q; i++) {
            res[l[i]] += v[i];
            res[r[i] + 1] -= v[i];
        }
        for (int i = 1; i < n; i++)
            res[i] += res[i - 1];
        for (int i = 0; i < n; i++)
            res[i] = min(res[i], c[i]);
        return res;
    }
    exit(1);
}

/**
3
10 15 13
2
0 2 20
0 1 -11


0 4 13
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 11 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 125 ms 8116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 81 ms 4948 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 58 ms 4948 KB Execution failed because the return code was nonzero
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 11 ms 360 KB Output is correct
6 Incorrect 125 ms 8116 KB Output isn't correct
7 Halted 0 ms 0 KB -