제출 #596947

#제출 시각아이디문제언어결과실행 시간메모리
596947PyishtellDetecting Molecules (IOI16_molecules)C++17
100 / 100
61 ms5224 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int,int>> p; for(int i=0; i<n; i++){ p.push_back({w[i],i}); } sort(p.begin(),p.end()); ll sum=0; vector<int> ans; for(int i=0; i<n && sum+p[i].first<=u; i++){ ans.push_back(p[i].second); sum += p[i].first; if(sum>=l) return ans; } ll maxSum=0; for(int j=0; j<ans.size(); j++){ maxSum += p[n-1-j].first; } if(maxSum<l) return vector<int>(0); for(int k=0; k<ans.size(); k++){ sum -= (p[k].first-p[n-1-k].first); ans[k] = p[n-1-k].second; if(sum>=l) return ans; } }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int j=0; j<ans.size(); j++){
      |                  ~^~~~~~~~~~~
molecules.cpp:26:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int k=0; k<ans.size(); k++){
      |                  ~^~~~~~~~~~~
molecules.cpp:9:27: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<pair<int,int>> p;
      |                           ^
#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...