Submission #451556

# Submission time Handle Problem Language Result Execution time Memory
451556 2021-08-03T08:49:10 Z T0p_ Distributing Candies (IOI21_candies) C++17
0 / 100
134 ms 10940 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+5;

int n, q;
long long arr[N], capacity[N];

vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    n = c.size(), q = l.size();
    for(int i=1 ; i<=n ; i++) capacity[i] = c[i-1];
    for(int i=0 ; i<q ; i++)
    {
        int a = l[i]+1, b = r[i]+1, c = v[i];
        if(c < 0) return {};
        arr[a] += c;
        arr[b+1] -= c;
    }
    for(int i=1 ; i<=n ; i++)
    {
        arr[i] += arr[i-1];
        arr[i] = min(arr[i], capacity[i]);
    }
    vector<int> ret;
    for(int i=1 ; i<=n ; i++) ret.push_back(arr[i]);
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 10940 KB Output isn't correct
2 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 -
# 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 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -