제출 #469906

#제출 시각아이디문제언어결과실행 시간메모리
469906IvnFDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>ans; vector<pair<int, int>>v; for(int i=0;i<w.size();++i){ v.pb({w[i], i}); } sort(v.begin(), v.end()); long long n=w.size(), kiri=0, sums=0, i=0; for(;i<n;++i){ int berat=v[i].first; sums+=berat while(sums > u) sums-=v[kiri++].first; if(sums>=l && sums<=u){ for(long long j=kiri;j<=i;++j) ans.push_back(v[j].second); return ans; } } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<w.size();++i){
      |                 ~^~~~~~~~~
molecules.cpp:16:20: error: expected ';' before 'while'
   16 |         sums+=berat
      |                    ^
      |                    ;
   17 |         while(sums > u) sums-=v[kiri++].first;
      |         ~~~~~