Submission #448007

# Submission time Handle Problem Language Result Execution time Memory
448007 2021-07-28T13:33:33 Z aris12345678 Distributing Candies (IOI21_candies) C++17
0 / 100
5000 ms 8888 KB
#include <bits/stdc++.h>
#include "candies.h"
using namespace std;

const int mxN = 200005;

bool sub2(vector<int> v) {
    int q = int(v.size());
    for(int i = 0; i < q; i++) {
        if(v[i] < 0)
            return false;
    }
    return true;
}

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = int(c.size()), q = int(l.size());
    vector<int> ans(n, 0);
    vector<int> pref(n, 0);
    if(sub2(v)) {
        for(int i = 0; i < q; i++) {
            pref[l[i]] += v[i];
            if(r[i] < n)
                pref[r[i]] -= v[i];
        }
        for(int i = 0; i < n; i++) {
            if(i > 0)
                pref[i] += pref[i-1];
            ans[i] = min(c[i], pref[i]);
        }
    } else {
        for(int i = 0; i < q; i++) {
            for(int j = l[i]; j <= r[i]; j++) {
                if(v[i] > 0)
                    ans[j] = min(c[j], ans[j]+v[i]);
                else
                    ans[j] = max(0, ans[j]+v[i]);
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 8880 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 Correct 222 ms 5720 KB Output is correct
3 Correct 228 ms 3828 KB Output is correct
4 Execution timed out 5033 ms 8888 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 533 ms 5716 KB Output is correct
4 Correct 539 ms 3484 KB Output is correct
5 Execution timed out 5048 ms 8884 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -