Submission #1042764

# Submission time Handle Problem Language Result Execution time Memory
1042764 2024-08-03T10:56:22 Z Zicrus Detecting Molecules (IOI16_molecules) C++17
10 / 100
1 ms 432 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;

typedef long long ll;

vector<int> find_subset(int l, int u, vector<int> w) {
    ll n = w.size();
    vector<pair<ll, ll>> s(n);
    for (int i = 0; i < n; i++) {
        s[i] = {w[i], i};
    }
    sort(s.begin(), s.end());

    ll tot = 0;
    vector<int> res;
    for (auto &e : s) {
        if (tot + e.first <= u) {
            tot += e.first;
            res.push_back(e.second);
        }
        else break;
    }

    ll id = n-1;
    ll resId = 0;
    while (tot < l && id >= res.size()) {
        tot += s[id].first - s[resId].first;
        res[resId] = s[id].second;
        id--; resId++;
    }

    return tot < l ? vector<int>() : res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:27:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (tot < l && id >= res.size()) {
      |                       ~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 432 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 392 KB OK (n = 12, answer = NO)
5 Correct 0 ms 348 KB OK (n = 12, answer = YES)
6 Correct 0 ms 348 KB OK (n = 12, answer = YES)
7 Correct 0 ms 348 KB OK (n = 12, answer = YES)
8 Correct 0 ms 348 KB OK (n = 12, answer = YES)
9 Correct 0 ms 348 KB OK (n = 6, answer = YES)
10 Correct 0 ms 348 KB OK (n = 12, answer = YES)
11 Correct 0 ms 348 KB OK (n = 100, answer = NO)
12 Correct 0 ms 348 KB OK (n = 100, answer = YES)
13 Correct 1 ms 348 KB OK (n = 100, answer = NO)
14 Correct 0 ms 348 KB OK (n = 100, answer = YES)
15 Correct 0 ms 348 KB OK (n = 100, answer = YES)
16 Correct 0 ms 348 KB OK (n = 100, answer = YES)
17 Correct 1 ms 344 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -