Submission #1015609

#TimeUsernameProblemLanguageResultExecution timeMemory
1015609UnforgettableplDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms436 KiB
#include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int>> arr; for(int i=0;i<w.size();i++)arr.emplace_back(w[i],i); sort(arr.begin(),arr.end()); int n = arr.size(); int totsum = 0; for(auto[a,b]:arr)totsum+=a; map<int,int> lookup; lookup[0]=n; int currsum = totsum; for(int i=n-1;i>=0;i--){ auto it1 = lookup.lower_bound(l-currsum); auto it2 = lookup.upper_bound(u-currsum); currsum-=arr[i].first; lookup[totsum-currsum]=i; if(it1==it2)continue; int ix = it1->second; vector<int> ans; for(int j=0;j<=i;j++)ans.emplace_back(arr[j].second); for(int j=ix;j<n;j++)ans.emplace_back(arr[j].second); return ans; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i=0;i<w.size();i++)arr.emplace_back(w[i],i);
      |                 ~^~~~~~~~~
#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...