답안 #81770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81770 2018-10-26T13:41:16 Z AngelKnows Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
using namespace std;
const int inf=0x3f3f3f3f;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	sort(w.begin(),w.end());
	vector<int> ans;
	int L=l,R=u;
	if (L<=w[0]&&w[0]<=R) {
		ans.push_back(w[0]);
		return ans;
	} else if (w[0]>R) {
		return vector<int>(0);
	} else if (w[0]<L) {
		int t=w.back();
		if (L<=t&&t<=R) {
			ans.push_back(t);
			return ans;
		} else if (t<L) {
			long long sum=0;
			for (int i=0;i<w.size();i++) {
				sum+=w[i];
				ans.push_back(w[i]);
				if (L<=sum&&sum<=R) {
					return ans;
				}
			}
			return vector<int>(0);
		}
	}
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:2: error: 'sort' was not declared in this scope
  sort(w.begin(),w.end());
  ^~~~
molecules.cpp:6:2: note: suggested alternative: 'short'
  sort(w.begin(),w.end());
  ^~~~
  short
molecules.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i=0;i<w.size();i++) {
                 ~^~~~~~~~~
molecules.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^