Submission #483699

#TimeUsernameProblemLanguageResultExecution timeMemory
483699StrawHatWessDetecting Molecules (IOI16_molecules)C++17
0 / 100
2 ms540 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) return pref; ROF(r,l+1,N){ cur+=a[r]; suf.pb(r); if(sz(pref)) cur-=a[pref.back()]; pref.pop_back(); if(cur>=L){ vi ans; ans.assign(all(pref)); for(int x: suf) ans.pb(x); return ans; } } return(vi{}); } /* 4 15 17 6 8 8 7 */

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:26:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   26 |         if(sz(pref)) cur-=a[pref.back()]; pref.pop_back();
      |         ^~
molecules.cpp:26:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   26 |         if(sz(pref)) cur-=a[pref.back()]; pref.pop_back();
      |                                           ^~~~
#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...