Submission #295776

#TimeUsernameProblemLanguageResultExecution timeMemory
295776aZvezdaDetecting Molecules (IOI16_molecules)C++14
100 / 100
62 ms8296 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}} #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl #include "molecules.h" std::vector<int> find_subset(int d, int u, std::vector<int> nt) { vector<pair<ll, int> > w; for(int i = 0; i < nt.size(); i ++) { w.push_back({nt[i], i}); } sort(w.begin(), w.end()); ll sum = 0, l = 0; for(int r = 0; r < w.size(); r ++) { sum += (ll)w[r].first; while(sum > u) { sum -= (ll)w[l].first; l ++; } if(d <= sum && sum <= u) { vector<int> ret; for(int i = l; i <= r; i ++) { ret.push_back(w[i].second); } return ret; } } return std::vector<int>(0); }

Compilation message (stderr)

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