Submission #617914

# Submission time Handle Problem Language Result Execution time Memory
617914 2022-08-01T17:03:21 Z sokratisi Distributing Candies (IOI21_candies) C++17
0 / 100
191 ms 14664 KB
#include "candies.h"
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size();
    vector<int> s(n, 0);
    int q = l.size();
    vector<pair<pair<int, int>, int>> edges;
    for (int i = 0; i < q; i++) {
        edges.push_back({{l[i], 1}, v[i]});
        edges.push_back({{r[i] + 1, 0}, v[i]});
    }
    sort(edges.begin(), edges.end());
    int pos = 0;
    int add = 0;
    for (int i = 0; i < n; i++) {
        while (edges[pos].first.first == i) {
            if (edges[pos].first.second) {
                add += edges[pos].second;
            }
            else {
                add -= edges[pos].second;
            }
            pos++;
        }
        s[i] = min(c[i], add);
    }

    return s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 191 ms 14664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -