Submission #297778

#TimeUsernameProblemLanguageResultExecution timeMemory
297778emnikDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms256 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; #define pb push_back #define all(x) begin(x), end(x) #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); std::vector<int> find_subset(int l, int r, vector<int> W){ vector<int> b; vector<pair<int, int>> a,Pair; for(int i=0; i < (int)W.size(); i++){ Pair.pb({W[i], i}); } sort(Pair.begin(), Pair.end()); ll sum=0, x=0, flag=0; for(int i=0; i < (int)Pair.size(); i++){ if(sum < l){ sum += (ll)Pair[i].first; a.pb({Pair[i].first, Pair[i].second}); } if(sum > r){ sum -= (ll)Pair[x].first; x++; } if(sum >= l && sum <= r){ flag=1; break; } } for(int i=x; i < (int)a.size(); i++){ b.pb(a[i].second); } return b; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:20: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
   19 |     ll sum=0, x=0, flag=0;
      |                    ^~~~
#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...