Submission #448008

# Submission time Handle Problem Language Result Execution time Memory
448008 2021-07-28T13:35:51 Z aris12345678 Distributing Candies (IOI21_candies) C++17
0 / 100
5000 ms 8900 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]+1] -= 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 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 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 228 ms 5716 KB Output is correct
3 Correct 223 ms 3828 KB Output is correct
4 Execution timed out 5055 ms 8884 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 531 ms 5728 KB Output is correct
4 Correct 555 ms 3524 KB Output is correct
5 Execution timed out 5043 ms 8900 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -