제출 #720498

#제출 시각아이디문제언어결과실행 시간메모리
720498joelgun14Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms300 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { // between l and u // pilih sum terkecil, terus nanti sort(w.begin(), w.end()); // cari w sesuai buat antara u l // cari first bigger than u, berarti countnya itu satu kurang dr long long sum = 0; int cnt = w.size(); for(int i = 0; i < w.size(); ++i) { sum += w[i]; if(sum > u) { cnt = i; break; } } if(cnt == 0) return vector<int>(0); multiset<int> s; sum = 0; for(int i = 0; i < cnt; ++i) { sum += w[i]; s.insert(w[i]); } multiset<int> unused; for(int i = cnt; i < w.size(); ++i) { // try to if(sum >= l && sum <= u) break; if(sum < l) { // coba increase to smallest above l s.insert(w[i]); sum += w[i]; sum -= *s.begin(); s.erase(s.begin()); } } if(sum >= l && sum <= u) { vector<int> ans; for(int i = 0; i < w.size(); ++i) { if(s.find(w[i]) != s.end()) { ans.push_back(i + 1); s.erase(s.find(w[i])); } } return ans; } else { return vector<int>(0); } }

컴파일 시 표준 에러 (stderr) 메시지

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