제출 #538743

#제출 시각아이디문제언어결과실행 시간메모리
538743fabijan_cikacHiring (IOI09_hiring)C++17
100 / 100
1339 ms60044 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define db double #define pp pair<db, db> #define ppp pair<db, pp> int n; db w; vector<db> sk; vector<db> q; vector<pair<db, int> > v; multiset<db> s; int siz = 0; map<db, multiset<pp> > mp; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> w; sk.resize(n); q.resize(n); for (int i = 0; i < n; ++i){ cin >> sk[i] >> q[i]; mp[q[i]].insert({sk[i], i + 1}); v.push_back({sk[i] / q[i], i}); } sort(v.begin(), v.end()); db sum = 0; db mini = 1e10; for (int i = 0; i < n; ++i){ db val = q[v[i].S]; s.insert(val); sum += val; while (!s.empty() && sum * v[i].F > w){ auto it = s.end(); --it; sum -= (*it); s.erase(it); } if (siz < s.size()) mini = sum * v[i].F; else if (siz == s.size()) mini = min(mini, sum * v[i].F); siz = max(siz, (int)(s.size())); } cout << siz << '\n'; s.clear(); sum = 0; for (int i = 0; i < n; ++i){ db val = q[v[i].S]; s.insert(val); sum += val; while (!s.empty() && sum * v[i].F > w){ auto it = s.end(); --it; sum -= (*it); s.erase(it); } if (siz == (int)(s.size()) && mini == sum * v[i].F){ while (!s.empty()){ auto it = s.begin(); db x = (*it); s.erase(it); auto it2 = mp[x].begin(); cout << (*it2).S << '\n'; mp[x].erase(it2); } break; } } return 0; }

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

hiring.cpp: In function 'int main()':
hiring.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (siz < s.size())
      |             ~~~~^~~~~~~~~~
hiring.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         else if (siz == 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...