Submission #712146

# Submission time Handle Problem Language Result Execution time Memory
712146 2023-03-18T08:39:38 Z danikoynov Distributing Candies (IOI21_candies) C++17
11 / 100
5000 ms 15324 KB
#include "candies.h"

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;

int n, q;
ll add[maxn], rem[maxn];
vector < int > s;
vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    n = c.size();
    q = l.size();
    s.resize(n, 0);
    bool all_positive = true;
    for (int i = 0; i < q; i ++)
        if (v[i] < 0)
        all_positive = false;

    if (all_positive)
    {
        for (int i = 0; i < q; i ++)
        {
            add[l[i]] += v[i];
            rem[r[i] + 1] += v[i];
        }

        ll sum = 0;
        for (int i = 0; i < n; i ++)
        {
            sum += add[i];
            sum -= rem[i];
            s[i] = min((ll)(c[i]), sum);
        }
        return s;
    }
    for (int i = 0; i < q; i ++)
    {
        for (int j = l[i]; j <= r[i]; j ++)
        {
            s[j] += v[i];
            if (s[j] < 0)
                s[j] = 0;
            if (s[j] > c[j])
                s[j] = c[j];
        }
    }
    return s;
}
# 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 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 11260 KB Output is correct
2 Correct 100 ms 15324 KB Output is correct
3 Correct 99 ms 15152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 503 ms 5032 KB Output is correct
3 Correct 465 ms 4668 KB Output is correct
4 Execution timed out 5046 ms 7244 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1402 ms 5032 KB Output is correct
4 Correct 1313 ms 3576 KB Output is correct
5 Execution timed out 5059 ms 7244 KB Time limit exceeded
6 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 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 97 ms 11260 KB Output is correct
7 Correct 100 ms 15324 KB Output is correct
8 Correct 99 ms 15152 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 503 ms 5032 KB Output is correct
11 Correct 465 ms 4668 KB Output is correct
12 Execution timed out 5046 ms 7244 KB Time limit exceeded
13 Halted 0 ms 0 KB -