Submission #199431

#TimeUsernameProblemLanguageResultExecution timeMemory
199431kshitij_sodaniDetecting Molecules (IOI16_molecules)C++17
69 / 100
1097 ms760 KiB
#include <iostream> #include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long int llo ; #define mp make_pair #define pb push_back #define a first #define b second vector<int> find_subset(int l,int u,vector<int> w){ vector<pair<int,int>> ww; if(l==2147483646){ while(true){ llo x=1; } } int n=w.size(); for(int i=0;i<n;i++){ ww.pb(mp(w[i],i)); } sort(ww.begin(),ww.end()); int pre[n]; int s[n]; pre[0]=ww[0].a; for(int i=1;i<n;i++){ pre[i]=pre[i-1]+ww[i].a; } s[n-1]=ww[n-1].a; for(int i=n-2;i>=0;i--){ s[i]=s[i+1]+ww[i].a; } vector<int> ans; for(int i=0;i<n;i++){ if(pre[i]<l and s[n-i-1]>=l){ int k=1; //cout<<i<<endl; while(true){ if(pre[k+i]-pre[k-1]<=u and pre[k+i]-pre[k-1]>=l){ for(int j=k;j<k+i+1;j++){ ans.pb(ww[j].b); } break; } else{ k+=1; } } break; } else if(pre[i]>=l and pre[i]<=u){ for(int j=0;j<i+1;j++){ ans.pb(ww[j].b); } break; } } return ans; } /* int main(){ vector<int> ss=find_subset(2147483646,2147483646,{1073741823,1073741823,1073741823}); for(int i=0;i<ss.size();i++){ cout<<ss[i]<<" "; } cout<<endl; return 0; }*/

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:8: warning: unused variable 'x' [-Wunused-variable]
    llo x=1;
        ^
#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...