답안 #159284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159284 2019-10-22T04:21:05 Z rama_pang Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 380 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

vector<int> find_subset(int l, int u, vector<int> w) {
    auto cmp = [&](int a, int b) {
        return w[a] < w[b];
    };

    vector<int> ord(w.size());
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), cmp);
    lint target = w[ord[0]];
    vector<int> res;
    int le = 0, ri = 0;

    while (le < w.size() && ri < w.size()) {
        if (l <= target && target <= u) {
            for (int i = le; i <= ri; i++) res.push_back(ord[i] + 1);
            break;
        } else if (target < l) {
            target += w[ord[++ri]];
        } else if (target > u) {
            target -= w[ord[le++]];
        }
    }
    return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (le < w.size() && ri < w.size()) {
            ~~~^~~~~~~~~~
molecules.cpp:18:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (le < w.size() && ri < w.size()) {
                             ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Correct 2 ms 376 KB OK (n = 12, answer = NO)
4 Correct 2 ms 376 KB OK (n = 12, answer = NO)
5 Incorrect 2 ms 380 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -