답안 #31064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31064 2017-08-06T15:00:34 Z platinant Detecting Molecules (IOI16_molecules) C++14
0 / 100
0 ms 1936 KB
#include "molecules.h"
#include <algorithm>
using namespace std;
typedef pair<int,int> pp;

vector<int> find_subset(int l, int u, vector<int> w) {
	
	vector<int> ret;
	vector<pp> a(w.size());
	for(int i=0;i<w.size();i++){
		a[i]=pp(w[i],i);
	}

	sort(a.begin(),a.end());

	int len=0,sum=0;
	while(len<a.size()&&sum<l){
		sum+=a[len].first;
		len++;
	}

	if(sum<=u){
		for(int i=0;i<len;i++)ret.push_back(a[i].second);
		return ret;
	}
	sum -= a[0].first;

	int L, R;
	for(R=len-1;R<w.size();R++){
		L=R-len+2;
		if(sum>=l){
			for(int i=L;i<=R;i++)ret.push_back(a[i].second);
			return ret;
		}
		if(R+1<w.size())sum+=a[R+1].first-a[L].first;
	}

    return vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w.size();i++){
               ^
molecules.cpp:17:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(len<a.size()&&sum<l){
           ^
molecules.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(R=len-1;R<w.size();R++){
               ^
molecules.cpp:35:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(R+1<w.size())sum+=a[R+1].first-a[L].first;
         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1936 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
2 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
3 Correct 0 ms 1936 KB OK (n = 12, answer = NO)
4 Correct 0 ms 1936 KB OK (n = 12, answer = NO)
5 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
6 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
7 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
8 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
9 Correct 0 ms 1936 KB OK (n = 6, answer = YES)
10 Correct 0 ms 1936 KB OK (n = 12, answer = YES)
11 Incorrect 0 ms 1936 KB sum of weights should be in [150..150] but it is 100
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1936 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1936 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1936 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1936 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -