제출 #1036576

#제출 시각아이디문제언어결과실행 시간메모리
1036576adkjtDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; //#define ll long long; #define f first #define s second long long mn[222222],mx[222222]; pair<int,int> s[222222]; deque<int> dq; vector<int> ans; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int sz=w.size(); for(int i=0;i<sz;i++) s[i].f=w[i],s[i].s=i; sort(s,s+sz); mn[0]=s[0].f; mx[sz-1]=s[sz-1].f; for(int i=1;i<sz;i++) { mn[i]=mn[i-1]+s[i].f; } for(int i=sz-2;i>=0;i--) mx[i]=mx[i+1]+s[i].f; //for(int i=0;i<sz;i++) cout<<mn[i]<<' '<<mx[i]<<'\n'; reverse(mx,mx+sz); //for(int i=0;i<sz;i++) cout<<mn[i]<<' '<<mx[i]<<'\n'; for(int i=0;i<sz;i++) { dq.push_back(s[i].s); //cout<<dq.front()<<' '<<dq.back()<<'\n'; //cout<<mx[i]<<'\n'; if(mx[i]>=l) { long long sum=mn[i]; int cnt=1,ch=0; while(sum<l) { sum-=s[dq.front()].f; sum+=s[dq.front()+i].f; dq.push_back(s[i+cnt].s); dq.pop_front(); cnt++; if(sum>u) {ch=1;break;} } if(ch) continue; while(!dq.empty()) ans.push_back(dq.front()),dq.pop_front(); return ans; } } return vector<int>(0); }
#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...