Submission #172067

#TimeUsernameProblemLanguageResultExecution timeMemory
172067arnold518Detecting Molecules (IOI16_molecules)C++14
69 / 100
1084 ms3832 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int N; ll L, R; pll A[MAXN+10]; vector<int> find_subset(int _L, int _R, vector<int> _A) { int i, j, k, l; L=_L; R=_R; N=_A.size(); for(i=1; i<=N; i++) A[i]={_A[i-1], i-1}; sort(A+1, A+N+1); for(i=1; i<=N; i++) { ll p=0, q=0; for(j=1; j<=i; j++) p+=A[j].first; for(j=N-i+1; j<=N; j++) q+=A[j].first; if(q<L || R<p) continue; vector<int> ans; if(L<=p && p<=R) { for(l=1; l<=i; l++) ans.push_back(A[l].second); return ans; } for(j=i; j>=1; j--) { if(p-A[j].first+A[N-i+j].first<L) { p=p-A[j].first+A[N-i+j].first; continue; } for(k=j+1; k<=N-i+j; k++) { p+=A[k].first-A[k-1].first; if(L<=p) { for(l=1; l<j; l++) ans.push_back(A[l].second); ans.push_back(A[k].second); for(l=N-i+j+1; l<=N; l++) ans.push_back(A[l].second); return ans; } } } } return vector<int>(); }
#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...