Submission #654816

#TimeUsernameProblemLanguageResultExecution timeMemory
654816sandry24Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second vi find_subset(int l, int u, vi w){ vector<pi> a; for(int i = 0; i < w.size(); i++) a.pb(mp(w[i], i+1)); sort(a.begin(), a.end()); int sum = 0, left = 0, right = 0; for(int i = 0; i < w.size(); i++){ if(sum + a[i].f <= u){ sum += a[i].f; right = i; } else break; } while(sum < l && right != w.size()-1){ sum -= a[left].f; sum += a[right+1].f; right++; left++; } if(sum < l) return {}; vi ans; for(int i = left; i <= right; i++) ans.pb(a[i].s); return ans; }

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < w.size(); i++)
      |                    ~~^~~~~~~~~~
molecules.cpp:18:22: 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:25:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     while(sum < l && right != w.size()-1){
      |                      ~~~~~~^~~~~~~~~~~~~
#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...