답안 #138282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138282 2019-07-29T16:46:56 Z arthurconmy Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
	#include "molecules.h"
#endif
using namespace std;

vector<int> find_subset(int l, int u, vector<int> W) 
{
    vector<int> use;
    int cur = 0;

    for(int i=0; i<W.size(); i++)
    {	
    	int w = W[i];

    	if(w>=l && w<=u)
    	{
    		return {w};
    	}

    	if(w<l)
    	{
    		use.push_back(i);
    		cur += w;
    		if(cur > u) break;
    	}
    }

    while(cur>u)
    {
    	if(use.empty()) return {};

    	cur -= W[use.back()];
    	use.pop_back();
    }

    if(use.empty()) return {};
    else return use;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<W.size(); i++)
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [302..304] but it is 300
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -