Submission #972328

# Submission time Handle Problem Language Result Execution time Memory
972328 2024-04-30T10:59:02 Z vjudge1 Detecting Molecules (IOI16_molecules) C++11
0 / 100
1 ms 348 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=l,b=u;
//	vector <long long> w;
//	long long n,a,b;
//	cin>>n>>a>>b;
	map <int,int> mp;
	for (int i=0; i<n; i++)
	{
		int x; cin>>x;
		w.pb(x);
		mp[x]=i;
	}
	sort(w.begin(),w.end());
	long long l1=n-1,r=n,sum=0;
	for (auto x:w) sum+=x;
	vector <int> ans;
	while (l1>=-1&&r>=0)
	{
		if (sum<=b&&sum>=a)
		{
			for (int i=0; i<=l1; i++) ans.pb(mp[w[i]]);
			for (int i=r; i<n; i++) ans.pb(mp[w[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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -