제출 #831327

#제출 시각아이디문제언어결과실행 시간메모리
831327SupersonicDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms340 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; std::vector<int> find_subset(int l, int u, std::vector<int> w) { ll n=w.size(); ll ls[n];ll rs[n]; vector<pair<ll,ll>> s; for(ll i=0;i<n;i++)s.push_back({w[i],i}); sort(s.begin(),s.end()); ls[0]=s[0].first;rs[0]=s[n-1].first; ll b=-1; if(ls[0]<=l&&u<=rs[0])b=0; if(ls[0]>=l&&ls[0]<=u)b=0; if(rs[0]>=l&&rs[0]<=u)b=0; for(ll i=1;i<n;i++){ ls[i]=ls[i-1]+s[i].first;rs[i]=rs[i-1]+s[n-1-i].first; if(ls[i]<=l&&u<=rs[i])b=i; if(ls[i]>=l&&ls[i]<=u)b=i; if(rs[i]>=l&&rs[i]<=u)b=i; //cerr<<ls[i]<<' '<<rs[i]<<endl; } //cerr<<b<<endl; if(b==-1)return {}; vector<pair<ll,ll>> rr; ll lp=0; for(ll i=0;i<=b;i++){rr.push_back(s[i]);lp+=s[i].first;} ll ci=0; ll ib=b; while(lp<l){ while(b<s.size()){ lp-=rr[ci].first; rr[ci]=s[b];lp+=s[b].first;b++; if(lp>=l)break; } if(lp>=l)break; ci++;ib++;b=ib;s.pop_back(); } vector<int> r; for(auto i:rr)r.push_back(i.second); return r; } //6 7 8 8

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:31:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       while(b<s.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...