Submission #617934

# Submission time Handle Problem Language Result Execution time Memory
617934 2022-08-01T17:12:09 Z sokratisi Distributing Candies (IOI21_candies) C++17
0 / 100
149 ms 14752 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 (pos < edges.size() && 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;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         while (pos < edges.size() && edges[pos].first.first == i) {
      |                ~~~~^~~~~~~~~~~~~~
# 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 149 ms 14752 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 212 KB Output isn't correct
2 Halted 0 ms 0 KB -