Submission #436170

# Submission time Handle Problem Language Result Execution time Memory
436170 2021-06-24T09:52:46 Z Mohammed_Atalah Distributing Candies (IOI21_candies) C++17
8 / 100
148 ms 10444 KB
#include "candies.h"
#include <bits/stdc++.h>
#include <vector>

using namespace std;

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) {

    int box = c.size();

    vector<long long> partial;
    partial.resize(box + 1);

    int e = l.size();
    for (int i = 0; i < e; i++) {
        partial[l[i]] += v[i];
        partial[r[i] + 1] -=  v[i];
    }
    // cout << partial[3] << endl;

    vector<long long> cum;
    cum.push_back(partial[0]);
    for (int i = 1; i < box; i++) {
        cum.push_back(cum[i - 1] + partial[i]);
    }


    vector<int> res;
    res.resize(box);
    for (int i = 0; i < box; i++) {
        if (cum[i] > 0) {
            res[i] = min(c[i] * 1ll, cum[i] );

        } else {
            res[i] = 0;
        }
    }

    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 10360 KB Output is correct
2 Correct 148 ms 10444 KB Output is correct
3 Correct 120 ms 10420 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 1 ms 204 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 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -