제출 #715659

#제출 시각아이디문제언어결과실행 시간메모리
715659ovidiush11Detecting Molecules (IOI16_molecules)C++14
19 / 100
1 ms304 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define ll long long std::vector<int> find_subset(int l, int u, std::vector<int> w) { ll n = w.size(); vector<pair<ll,ll>> a(n); for(ll i = 0;i < n;i++)a[i] = {w[i],i}; sort(a.begin(),a.end()); ll N = n,s = 0; while(N != 0 && s + w[N-1] < l){s += a[N-1].first;N--;} if(N == n) { for(int i = 0;i < n;i++)if(w[i] >= l && w[i] <= u)return {i}; return {}; } if(N == 0)return {}; N = n - N;s = 0; vector<pair<ll,ll>> p(n-N); for(ll i = N;i < n;i++)p[i-N] = a[i]; for(ll i = 0;i < N-1;i++)s += a[i].first; ll k = 0; for(ll i = N-1;i < n;i++) { s += a[i].first; ll left = 0,right = n-N-1; while(left != right) { ll mid = (left + right) / 2; if(p[mid].first + s < l)left++; else if(p[mid].first + s > u)right--; else left = right = mid; } if(p[left].first + s >= l && p[left].first + s <= u) { vector<int> ans; for(ll j = i;j >= k;j--)ans.push_back(a[j].second); ans.push_back(p[left].second); return ans; } s -= a[k].first; if(k < p.size())p[k] = a[k]; k++; } return {}; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:46:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if(k < p.size())p[k] = a[k];
      |            ~~^~~~~~~~~~
#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...