Submission #1015611

#TimeUsernameProblemLanguageResultExecution timeMemory
1015611UnforgettableplDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long std::vector<int32_t> find_subset(int32_t l, int32_t u, std::vector<int32_t> 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<int32_t> 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(int32_t, int32_t, std::vector<int>)':
molecules.cpp:8:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     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...