제출 #319583

#제출 시각아이디문제언어결과실행 시간메모리
319583knon0501Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> ans; vector<pair<int,int>> a; for(int i=0 ; i<w.size() ; i++)a.push_back({w[i],i}); sort(a.begin(),a.end()); int idx=0; for(auto k: w){ if(k>=l && k<=u){ ans={idx}; return ans; } idx++; } long long s=0; for(int i=(int)w.size()-1 ; i>= 0; i--){ int k=a[i].first; if(k<l){ s+=k; ans.push_back(a[i].second); } if(s>=l && s<=r){ sort(ans.begin(),ans.end()); return ans; } } return {}; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0 ; i<w.size() ; i++)a.push_back({w[i],i});
      |                   ~^~~~~~~~~
molecules.cpp:26:23: error: 'r' was not declared in this scope
   26 |         if(s>=l && s<=r){
      |                       ^