답안 #284113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284113 2020-08-26T20:47:57 Z IBMG Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    long au = 0;
    int iz = 0, de = w.size()+1;
    vector < pair < int, int > > v;
    vector < int > ans;
    for (int i = 0; i < w.size(); i ++)
    {
        v.push_back(make_pair(w[i], i+1));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i ++)
    {
        au += v[i].first;
        if (au >= u)
        {
            de = i;
            break;
        }
    }
    while (au > u)
    {
        au -= v[iz].first;
        iz ++;
    }
    if (au >= l && au <= u)
    {
        for (int i = iz; i <= de; i ++)
        {
            ans.push_back(v[i].second);
        }
    }
    sort(ans.begin(), ans.end());
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 0; i < w.size(); i ++)
      |                     ~~^~~~~~~~~~
molecules.cpp:16: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]
   16 |     for (int i = 0; i < v.size(); i ++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -