답안 #959415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959415 2024-04-08T07:20:37 Z Mystic03 Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 348 KB
#include "molecules.h"

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int p1 = 0;
    int r = 0;

    int currSum = 0;

    while (currSum < l) {
        currSum += w[r];
        r++;
    }

    if (currSum <= u) {
        return std::vector<int>(w.begin(), w.begin() + r);
    }
    r--;
    currSum -= w[r];

    for (int i = r; i < w.size(); i++) {
        currSum += w[i];
        currSum -= w[p1++];
        if (currSum >= l && currSum <= u) {
            return std::vector<int>(w.begin() + p1, w.end() + i + 1);
        }
    }
    return std::vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = r; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer 18 violates the range [0, 12]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -