제출 #293755

#제출 시각아이디문제언어결과실행 시간메모리
293755HemimorDetecting Molecules (IOI16_molecules)C++14
100 / 100
59 ms5880 KiB
#include "molecules.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vi find_subset(int l,int u,vi w){
	int n=w.size();
	vp a(n);
	for(int i=0;i<n;i++) a[i]={w[i],i};
	sort(a.begin(),a.end());
	ll L=0,R=0,x=a[0].first;
	vi b;
	for(int i=0;i<n;i++){
		L+=a[i].first-x;
		R+=a[n-i-1].first-x;
		ll ls=x*(i+1)+L,rs=x*(i+1)+R,t=ls;
		if(u<ls||rs<l) continue;
		if(l<=t&&t<=u){
			for(int j=0;j<=i;j++) b.push_back(a[j].second);
		}
		else{
			for(int j=0;j<=i;j++){
				t-=a[i-j].first;
				t+=a[n-j-1].first;
				if(l<=t&&t<=u){
					for(int k=0;k<i-j;k++) b.push_back(a[k].second);
					for(int k=0;k<=j;k++) b.push_back(a[n-k-1].second);
					break;
				}
			}
		}
		break;
	}
	sort(b.begin(),b.end());
	return b;
}
#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...