답안 #69051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69051 2018-08-19T15:30:58 Z TuGSGeReL Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back
#define ss second
#define ff first
#define ext exit(0)
using namespace std;
int i;
ll s;
vector<pair<int,int> >v;
vector<int> find_subset(int l, int u, vector<int> w) {
	for(i=0;i<w.size();i++) v.pub(mp(w[i],i));
	sort(v.begin(),v.end());
	deque<pair<int,int> >ans1;
	vector<int>ans;
	for(i=0;i<v.size();i++){
		if(s+v[i].ff<=u){
			s+=v[i].ff;
			ans1.pub(v[i]);
		}
		else if(s-ans1[0].ff+v[i].ff<=u){
			s-=ans1[0].ff-v[i].ff;
			ans1.pop_front();
			ans1.pub(v[i]));
		}
	}
	for(i=0;i<ans1.size();i++){
		ans.pub(ans1[i].ss);
	}
	return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<w.size();i++) v.pub(mp(w[i],i));
          ~^~~~~~~~~
molecules.cpp:19:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<v.size();i++){
          ~^~~~~~~~~
molecules.cpp:27:18: error: expected ';' before ')' token
    ans1.pub(v[i]));
                  ^
molecules.cpp:30:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<ans1.size();i++){
          ~^~~~~~~~~~~~