제출 #239557

#제출 시각아이디문제언어결과실행 시간메모리
239557nicolaalexandraDetecting Molecules (IOI16_molecules)C++14
69 / 100
102 ms14456 KiB
#include <bits/stdc++.h> #include "molecules.h" #define DIM 200010 using namespace std; multiset <pair<int,int> > s; vector <int> sol; pair <int,int> v[DIM]; int i,k; vector <int> find_subset (int l, int r, vector <int> w){ for (i=0;i<w.size();i++) v[++k] = make_pair(w[i],i); sort (v+1,v+k+1); int sum = 0; for (i=1;i<=k;i++){ if (sum + v[i].first < l){ sum += v[i].first; s.insert(make_pair(v[i].first,v[i].second)); continue; } if (sum + v[i].first >= l && sum + v[i].first <= r){ sum += v[i].first; s.insert(make_pair(v[i].first,v[i].second)); break; } /// sum + v[i].first > r s.insert(make_pair(v[i].first,v[i].second)); sum += v[i].first; int val = sum - r; multiset <pair<int,int> > :: iterator it = s.lower_bound(make_pair(val,0)); sum -= it->first; s.erase(it); if (sum >= l && sum <= r) break; } if (sum >= l && sum <= r){ for (auto it : s) sol.push_back(it.second); sort (sol.begin(),sol.end()); } return sol; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (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...