Submission #729130

#TimeUsernameProblemLanguageResultExecution timeMemory
729130NintsiChkhaidzeDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #define pb push_back #include "molecules.h" using namespace std; vector <int> w; bool cmp(int x,int y){ return (w[x] < w[y]); } vector<int> find_subset(int l, int u, vector<int> k) { vector <int> a; a.clear(); w = k; for (int i=0;i<w.size();i++) a.pb(i); sort(a.begin(),a.end(),cmp); long long s = 0; int r = 0,L=-1,R=0; for (int i = 0; i < w.size(); i++){ while (r < w.size() && s + w[a[r]] <= u) s += w[a[r++]]; if (s >= l && s <= u) { L = i,R = r - 1; break; } s -= w[i]; } vector <int> res; res.clear(); for (int i = L; i <= R; i++) res.pb(a[i]); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (int i=0;i<w.size();i++) a.pb(i);
      |               ~^~~~~~~~~
molecules.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for (int i = 0; i < w.size(); i++){
      |                  ~~^~~~~~~~~~
molecules.cpp:19:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   while (r < w.size() && s + w[a[r]] <= u) s += w[a[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...