제출 #305532

#제출 시각아이디문제언어결과실행 시간메모리
305532juggernautDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<int>find_subset(int a,int b,vector<int>w){ vector<int>ans; vector<pair<int,int>>v; int i,sum=0,l,r=0; for(;r<w.size();r++)v.push_back({w[r],r}); sort(v.begin(),v.end()); for(r=0;r<w.size();r++){ sum+=v[i].first; while(sum>r)sum-=v[j++].first; if(sum>=l){ for(;l<=r;l++)ans.push_back(v[l].second); return ans; } } return {}; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(;r<w.size();r++)v.push_back({w[r],r});
      |          ~^~~~~~~~~
molecules.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(r=0;r<w.size();r++){
      |             ~^~~~~~~~~
molecules.cpp:11:28: error: 'j' was not declared in this scope
   11 |         while(sum>r)sum-=v[j++].first;
      |                            ^