Submission #584619

#TimeUsernameProblemLanguageResultExecution timeMemory
584619Newtech66Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms304 KiB
#include<bits/stdc++.h> using namespace std; using lol=long long int; #define endl "\n" const lol mod1=1e9+7,mod2=998244353,mod3=1000000000000000003; const lol inf=1e18+8; const double eps=1e-12; const double PI=acos(-1.0); const int N=3e5+5; #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> find_subset(int l,int u,vector<int> w) { int n=(int)w.size(); vector<int> ans; lol S=0; vector<pair<int,int>> v(n); for(int i=0;i<n;i++) v[i]={w[i],i}; sort(v.begin(),v.end()); bool found=false; for(int i=n-1;i>=0;i--) { if(l<=S && S<=u) { found=true; break; } if(S<l && S+v[i].first>u) break; ans.push_back(v[i].second); S+=v[i].first; } if(found) return ans; if(ans.size()==n) { ans.clear(); return ans; } S+=v[0].first; ans.push_back(v[0].second); if(l<=S && S<=u) return ans; else { ans.clear(); return ans; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:37:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(ans.size()==n)
      |        ~~~~~~~~~~^~~
#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...