제출 #484443

#제출 시각아이디문제언어결과실행 시간메모리
484443StrawHatWessDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms204 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int>vi; #define pb push_back #define sz(v) (int)v.size() #define all(x) begin(x),end(x) #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=b-1; i>=a; i--) //------------------------------------------------- vi find_subset(int L, int R, vi a) { int N=sz(a); sort(all(a)); int l=-1; ll cur=0; vi pref,suf; while(l+1<N && cur+a[l+1]<=R){ l++; cur+=a[l]; pref.pb(l); } if(cur>=L && cur<=R) return pref; ROF(r,0,N){ cur+=a[r]; suf.pb(r); if(cur>R && sz(pref)){ cur-=a[pref.back()]; pref.pop_back(); } if(cur>=L && cur<=R){ vi ans; for(int x: pref) ans.pb(x); for(int x: suf) ans.pb(x); sort(all(ans)); return ans; } } return(vi{}); } /* 4 15 17 6 8 8 7 */ /* 4 14 15 5 5 6 6 */
#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...