제출 #719975

#제출 시각아이디문제언어결과실행 시간메모리
719975vinnipuh01Detecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms336 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector <int> v; vector<int> find_subset(int l , int u , vector<int> w) { set <pair<int, int> > st, s; int sum = 0; sort( w.begin(), w.end() ); if ( w.front() > u ) { vector <int> v; return v; } else if ( w.front() <= u && w.front() >= l ) { vector <int> v; v.push_back( 0 ); return v; } for ( int i = 0; i < w.size(); i ++ ) { if ( sum + w[ i ] <= u ) st.insert( { w[ i ], i } ), sum += w[ i ]; else s.insert( { w[i ], i } ); } assert( sum <= u ); while ( sum < l ) { if ( !s.size() ) break; sum += s.rbegin()->first - st.begin()->first; st.erase( st.begin() ); st.insert( *s.rbegin() ); s.erase( --s.end() ); } vector <int> v; v.clear(); if ( sum < l ) return v; for ( auto i : st ) v.push_back( i.second ); return v; } //main () { // int l, r; // cin >> l >> r; // int n; // cin >> n; // int num; // for ( int i = 1; i <= n; i ++ ) { // cin >> num; // v.push_back( num ); // } // v = find_subset( l, r, v ); // if ( v.size() ) // cout << "YES\n"; // else // cout << "NO\n"; //}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for ( int i = 0; 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...