Submission #442952

# Submission time Handle Problem Language Result Execution time Memory
442952 2021-07-09T11:47:38 Z benedict0724 Distributing Candies (IOI21_candies) C++17
8 / 100
131 ms 12940 KB
#include "candies.h"

#include <vector>
using namespace std;
typedef long long ll;

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size();
    int q = l.size();
    std::vector<ll> s(n);
    for(int i=0;i<q;i++)
    {
        s[l[i]] += v[i];
        if(r[i] < n-1) s[r[i]+1] -= v[i];
    }
    for(int i=1;i<n;i++) s[i] += s[i-1];
    for(int i=0;i<n;i++) s[i] = min(s[i], (ll)c[i]);
    vector<int> ans(n);
    for(int i=0;i<n;i++) ans[i] = s[i];
    return ans;
}
# 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 Correct 131 ms 8796 KB Output is correct
2 Correct 122 ms 12940 KB Output is correct
3 Correct 123 ms 12696 KB Output is correct
# 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 -