제출 #533867

#제출 시각아이디문제언어결과실행 시간메모리
533867M_WDetecting Molecules (IOI16_molecules)C++11
100 / 100
46 ms6176 KiB
#include "molecules.h" #include <bits/stdc++.h> #define ii pair<int, int> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<ii> a; for(int i = 0; i < w.size(); i++) a.push_back({w[i], i}); sort(a.begin(), a.end()); int k = 0; long long pref = 0, suf = 0; for(; k < w.size(); k++){ pref += a[k].first * 1ll; suf += a[w.size() - k - 1].first * 1ll; if(pref <= u && suf >= l) break; } for(int i = k; i < w.size(); i++){ if(pref >= l && pref <= u){ vector<int> ans; for(int j = i - k; j <= i; j++) ans.push_back(a[j].second); return ans; } pref += (a[i + 1].first - a[i - k].first) * 1ll; } return std::vector<int>(0); }

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

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