Submission #668375

# Submission time Handle Problem Language Result Execution time Memory
668375 2022-12-03T17:56:09 Z haxorman Detecting Molecules (IOI16_molecules) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;

vector<int> find_subset(int l, int r, vector<int> arr) {
    vector<pair<int,int>> vec;
    for (int i = 0; i < arr.size(); ++i) {
        vec.push_back({arr[i], i + 1});
    }
    sort(vec.begin(), vec.end());
    
    long long sum = 0;
    set<pair<int,int>> check;
    for (int i = 0; i < vec.size(); ++i) {
        while (sum > r) {
            sum -= (*check.rbegin()).first;
            check.erase(*check.rbegin());
        }

        if (sum >= l) {
            vector<int> ans;
            for (auto p : check) {
                ans.push_back(p.second);
            }
            return ans;
        }

        check.insert(vec[i]);
        sum += vec[i].first;
    }
    while (sum > r) {
        sum -= (*check.rbegin()).first;
        check.erase(*check.rbegin());
    }

    if (sum >= l) {
        vector<int> ans;
        for (auto p : check) {
            ans.push_back(p.second);
        }
        return ans;
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for (int i = 0; i < arr.size(); ++i) {
      |                     ~~^~~~~~~~~~~~
molecules.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < vec.size(); ++i) {
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB OK (n = 1, answer = NO)
2 Correct 0 ms 212 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB OK (n = 1, answer = NO)
2 Correct 0 ms 212 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB OK (n = 1, answer = NO)
2 Correct 0 ms 212 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB OK (n = 1, answer = NO)
2 Correct 0 ms 212 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB OK (n = 1, answer = NO)
2 Correct 0 ms 212 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -