답안 #1087175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087175 2024-09-12T09:12:13 Z MahmytM Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
int main(){
	int n,l,u;
	cin>>n>>l>>u;
	int w[n+2];
	for(int i=0;i<n;i++){
		cin>>w[i];
	}
	vector<int> result;
	int sum=0;
	for(int i=0;i<n;i++){
		if(sum+w[i]<u){
			sum+=w[i];
			result.pb(i);
		}
	}
	if(sum>=l and sum<=u){
		for(int i=0;i<result.size();i++){
			cout<<result[i]<<' ';
		}
	}else{
		cout<<0<<endl;
	}
}

Compilation message

molecules.cpp: In function 'int main()':
molecules.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int i=0;i<result.size();i++){
      |               ~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccuH8kI6.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJLXHZ6.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccuH8kI6.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status