제출 #484483

#제출 시각아이디문제언어결과실행 시간메모리
484483_BodyDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms204 KiB
#include "molecules.h" //#include"grader.cpp" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>res; vector<pair<long long,int>>arr; int n=w.size(); for(int i=0;i<n;i++) { if(w[i]>=l&&w[i]<=u) { res.push_back(i+1); return res; } // if(w[i]<l) // { arr.push_back({w[i],i}); // } } sort(arr.begin(),arr.end()); long long sum=0; ///int l=0; deque<int>deq; bool is=false; for(int i=0;i<arr.size();i++) { deq.push_back(arr[i].second); sum+=arr[i].first; if(sum>=l&&sum<=u) { is=true; break; } if(sum>u) { while(sum>u) { sum-=(w[deq.front()]); deq.pop_front(); } if(sum<=u&&sum>=l) { is=true; break; } } } if(!is) { vector<int>em(0); return em; } for(auto x:deq) res.push_back((x+1)); return res; } /* 4 15 17 6 8 8 7 */

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

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