Submission #40146

#TimeUsernameProblemLanguageResultExecution timeMemory
40146tmwilliamlin168Detecting Molecules (IOI16_molecules)C++11
100 / 100
71 ms4648 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; vector<int> find_subset( int L, int U, vector<int> W){ vector< int > ord( W.size() ), result; for( int i = 0; i < W.size(); ++i ){ ord[ i ] = i; } sort( ord.begin(), ord.end(), [ & ]( int i, int j ){ return W[ i ] < W[ j ]; } ); ll sum = 0; for( int lb = 0, rb = 0; lb < W.size(); ++lb ){ while( sum < L and rb < W.size() ) sum += W[ ord[ rb++ ] ]; if( L <= sum and sum <= U ){ for( int i = lb; i < rb; ++i ) result.push_back(ord[ i ]); break; } if( lb < rb ) sum -= W[ ord[ lb ] ]; } return result; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for( int i = 0; i < W.size(); ++i ){
                     ^
molecules.cpp:14:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for( int lb = 0, rb = 0; lb < W.size(); ++lb ){
                               ^
molecules.cpp:15:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while( sum < L and rb < W.size() )
                           ^
#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...