Submission #297851

#TimeUsernameProblemLanguageResultExecution timeMemory
297851MuhammetaliDetecting Molecules (IOI16_molecules)C++11
69 / 100
59 ms6920 KiB
#include "molecules.h" #include <bits/stdc++.h> #define mp make_pair #define f first #define s second #define sz(x) (int)(x).size() #define rsz resize #define ins insert #define ft front() #define bk back() #define pf push_front #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pl; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; vi find_subset(int l, int u, vi w) { int n=sz(w); int jem[n]={0}; vpl par; for (int i=0;i<n;i++)par.pb({w[i],i}); sort(par.begin(),par.end()); vi res; jem[-1]=0; jem[0]=par[0].f; for (int i=1;i<n;i++) jem[i]+=jem[i-1]+par[i].f; int ff=0,ss=0; while(ff<=ss && ff<n && ss<n) { ll g=jem[ss]-jem[ff-1]; if (g>=l && g<=u) { for (int i=ff;i<=ss;i++) { res.pb(par[i].s); } return res; } if (g>u)ff++; if (g<l)ss++; } return res; }

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:34:8: warning: array subscript -1 is below array bounds of 'int [(<anonymous> + 1)]' [-Warray-bounds]
   34 |  jem[-1]=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...