Submission #288808

#TimeUsernameProblemLanguageResultExecution timeMemory
288808Ruba_KDetecting Molecules (IOI16_molecules)C++14
69 / 100
1088 ms12932 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std ; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); deque<int>pos (n); iota(pos.begin() , pos.end() , 0); sort(pos.begin() , pos.end() , [w](int a , int b){ return w[a] < w[b] ; }); pos.push_back(0); sort(w.begin() , w.end()); if(w[0] > u)return {}; w.push_back((2 << 31) + 1); long long sum = 0 ; int idx = 0 ; deque<pair<int , int > > ret ; for(int i = 0 ; i < n ; i ++){ ret.push_back({w[i] , pos[i]}); sum += w[i]; while(sum > u){ sum -= ret.front().first ; ret.pop_front(); } if(sum >= l && sum <= u){ vector<int>ans ; for(auto f : ret) ans.push_back(f.second); sort(ans.begin() , ans.end()); return ans ; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:20: warning: result of '(2 << 31)' requires 34 bits to represent, but 'int' only has 32 bits [-Wshift-overflow=]
   22 |     w.push_back((2 << 31) + 1);
      |                  ~~^~~~~
molecules.cpp:26:9: warning: unused variable 'idx' [-Wunused-variable]
   26 |     int idx = 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...