답안 #167871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167871 2019-12-10T16:48:00 Z Peacher29 Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include "molecules.h"

#include<bits/stdc++.h>

using namespace std;

bool b[200000];

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pair<int,int>> p(w.size());
	vector<int> er;
	int n=w.size();
	for(int i=0;i<w.size();i++){
		p[i].first=w[i];
		p[i].second=i;
	}
	sort(p.begin(),p.end());
	long long osszeg=0;
	for(int i=p.size()-1;i>=0 && osszeg < l ; i--){
		osszeg+=p[i].first;
		b[i]=1;
	}
	int p1=p.size()-1, p2=0;
	while(osszeg>u){
		while(p2<n && osszeg-p[p1].first+p[p2].first<l){
			p2++;
		}
		if(b[p2]){
			break;
		}
		if(!b[p1]){
			break;
		}
		b[p2]=1;
		b[p1]=0;
		osszeg-=p[p1].first;
		osszeg+=p[p2].first;
	}
	for(int i=0;i<n;i++){
		if(b[i])
			er.push_back(p[i].second);
	}
	return er;
}

Compilation message

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