답안 #61053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61053 2018-07-25T07:02:20 Z Tenuun Detecting Molecules (IOI16_molecules) C++17
0 / 100
3 ms 536 KB
#include "molecules.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<int>res;
	vector<pair<int, int> >v;
	for(int i=0; i<w.size(); i++){
		v.push_back({w[i], i});
	}
	sort(v.rbegin(), v.rend());
	long long curr=0;
	int r=0;
	for(int i=0; i<v.size(); i++){
		r=max(r, i);
		if(i==r){
			curr=v[i].first;
			res.clear();
			res.push_back(v[i].second);
		}
		while(r+1<v.size() && curr<l){
			curr+=v[r+1].first;
			res.push_back(v[r+1].second);
			r++;
		}
		if(curr>=l && curr<=u) return res;
		curr-=v[i].first;
		res.erase(res.begin());
	}
	if(curr>=l && curr<=u) return res;
	else return res={0}, res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<w.size(); i++){
               ~^~~~~~~~~
molecules.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++){
               ~^~~~~~~~~
molecules.cpp:22:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(r+1<v.size() && curr<l){
         ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 484 KB OK (n = 12, answer = YES)
2 Correct 3 ms 536 KB OK (n = 12, answer = YES)
3 Incorrect 3 ms 536 KB sum of weights should be in [307..317] but it is 50
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -