답안 #972315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972315 2024-04-30T10:48:02 Z vjudge1 Detecting Molecules (IOI16_molecules) C++11
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define double long double
#define pon ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  int T=1;
#define ponchik signed main
#define pb push_back
#define pf push_front
#define endl "\n"
#define F first
#define S second

const long long N=1e5+69,INF=1e18+1488;

vector<int> find_subset(int l, int u, vector<int> w)
//int main()
{
	long long n=w.size(),a=l1,b=u;
//	vector <long long> w;
//	cin>>n>>a>>b;
//	for (int i=0; i<n; i++)
//	{
//		int x; cin>>x;
//		w.pb(x);
//	}
	sort(w.begin(),w.end());
	long long l1=n-1,r=n,sum=0;
	for (auto x:w) sum+=x;
	vector <int> ans;
//	cout<<sum<<endl;
	while (l1>=-1&&r>=0)
	{
		if (sum<=b&&sum>=a)
		{
			for (int i=0; i<=l1; i++) ans.pb(i);
			for (int i=r; i<n; i++) ans.pb(i);
			break;
		}
		if (sum>b)
		{
			sum-=w[l1];
			l1--;
		}
		else if (sum<a)
		{
			r--;
			sum+=w[r];
		}
	}
//	for (auto x:ans) cout<<x<<" ";
	return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:25: error: 'l1' was not declared in this scope; did you mean 'l'?
   19 |  long long n=w.size(),a=l1,b=u;
      |                         ^~
      |                         l
molecules.cpp:34:12: error: 'b' was not declared in this scope
   34 |   if (sum<=b&&sum>=a)
      |            ^
molecules.cpp:40:11: error: 'b' was not declared in this scope
   40 |   if (sum>b)
      |           ^