Submission #1274492

#TimeUsernameProblemLanguageResultExecution timeMemory
1274492KluydQDetecting Molecules (IOI16_molecules)C++20
100 / 100
35 ms6172 KiB
#include "molecules.h"
#include <bits/stdc++.h>

//#define respagold ios_base::sync_with_stdio(0), cin.tie(0);
//#define int long long
#define ll long long
#define int2 __int128_t
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define pii pair <int, int>
#define ppi pair <pair <int, int>, int>
#define pip pair <int, pair <int, int>>
#define mkp make_pair

using namespace std;
 
const int N = 1e5 + 12;
const int mod = 1e9 + 7;
const int inf = 1e9;

ll n, m, x, y;

vector <int> find_subset( int l, int u, vector <int> a )
{
	x = l, y = u, n = sz(a);
	vector <pair <ll, ll>> b;
	
	FOR( i, 0, n - 1, 1 ) b.pb({a[i], i});
	sort( all(b) ); vector <int> res;
	
	ll r = 0; ll sum = b[0].F;
	
	FOR( i, 0, n - 1, 1 )
	{
		while( r < n - 1 && sum < x ) r ++, sum += b[r].F;
		
		if( x <= sum && sum <= y && b[r].F - b[i].F <= y - x )
		{
			FOR( j, i, r, 1 ) res.pb(b[j].S);
			return res;
		}
		sum -= b[i].F;
		if( r == i ) r = i + 1, sum = a[r];
	}
	return res;
}
/*
signed main()
{
	respagold;
	
	int test = 1;
	if( !test ) cin >> test;
	while( test -- ) solve();
}*/

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...