제출 #952044

#제출 시각아이디문제언어결과실행 시간메모리
952044Angus_YeungHiring (IOI09_hiring)C++17
60 / 100
298 ms22704 KiB
#include <bits/stdc++.h> #define val first #define id second #define pii pair<ll, ll> typedef long long ll; const ll MOD = 1000000007LL; const ll INF = 1e15; using namespace std; struct worker { ll s, q, id; }; ll n, w, sum, ans; worker a[500010]; priority_queue<pii> q; long double f(worker x) { return x.s*1.0/x.q; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> n >> w; for (int i = 1; i <= n; i++) { cin >> a[i].s >> a[i].q; a[i].id = i; } sort(a+1, a+n+1, [&](worker x, worker y) -> bool { return f(x) < f(y); }); sum = 0; ans = 0; while (!q.empty()) q.pop(); for (int i = 1; i <= n; i++) { q.push({a[i].q, a[i].id}); sum += a[i].q; while (!q.empty() && f(a[i])*sum > w) { sum -= q.top().val; q.pop(); } ans = max(ans, (ll)q.size()); } if (ans == 0) { cout << "0\n"; return 0; } sum = 0; while (!q.empty()) q.pop(); for (int i = 1; i <= n; i++) { q.push({a[i].q, a[i].id}); sum += a[i].q; while (!q.empty() && f(a[i])*sum > w) { sum -= q.top().val; q.pop(); } if (q.size() == ans) { cout << ans << "\n"; while (!q.empty()) { cout << q.top().id << "\n"; q.pop(); } return 0; } } return 0; }

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

hiring.cpp: In function 'int main()':
hiring.cpp:61:16: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   61 |   if (q.size() == ans) {
      |       ~~~~~~~~~^~~~~~
#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...