Submission #370455

#TimeUsernameProblemLanguageResultExecution timeMemory
370455amano_hinaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms384 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { long long n=w.size(); sort(w.begin(),w.end()); vector<int> ans; long long mn=0,mx=0,cnt; bool d=1; for(long long i=0;i<n;i++) { mn=mn+w[i]; mx=mx+w[n-1-i]; if(mn>=l&&mn<=u) { for(long long j=0;j<=i;j++) { ans.push_back(j); } break; } else if(mx>=l&&mx<=u) { for(long long j=n-1;j>=n-1-i;j--) { ans.push_back(j); } break; } else if(mn<l&&u<mx) { cnt=mn; for(long long j=i;j>=0;j--) { cnt=cnt-w[j]+w[n-1-(i-j)]; if(cnt>=l&&cnt<=u) { for(long long k=0;k<j;k++) { ans.push_back(k); } for(long long k=n-1;k>=n-1-(i-j);k--) { ans.push_back(k); } break; } } break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:10: warning: unused variable 'd' [-Wunused-variable]
    9 |     bool d=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...