제출 #817983

#제출 시각아이디문제언어결과실행 시간메모리
817983LiudasHiring (IOI09_hiring)C++17
60 / 100
1581 ms15644 KiB
#include <bits/stdc++.h> #define endl "\n" using namespace std; struct node{ double Q; double P; int id; }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long N, W; double H = 0, BP = 1e18; cin >> N >> W; vector<node> arr(N); vector<int> ans; for(int i = 0; i < N; i ++){ cin >> arr[i].P >> arr[i].Q; arr[i].id = i + 1; } sort(arr.begin(), arr.end(), [&](node a, node b){return a.Q < b.Q;}); double l = 0, r = 1e16; for(int i = 0; i < N; i ++){ node start = arr[i]; double kof = start.P/start.Q; double price = 0; double c = 0; vector<int> brr; for(node j : arr){ if(kof >= j.P/j.Q && (price + j.Q) * kof <= W){ c ++; price += j.Q; brr.push_back(j.id); } } if(H < c){ ans = brr; BP = price * kof; } else if(H == c && price * kof <= BP){ ans = brr; BP = price * kof; } H = max(c, H); } cout << H << endl; sort(ans.begin(), ans.end()); for(int i : ans){ cout << i << endl; } return 0; }

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

hiring.cpp: In function 'int main()':
hiring.cpp:24:12: warning: unused variable 'l' [-Wunused-variable]
   24 |     double l = 0, r = 1e16;
      |            ^
hiring.cpp:24:19: warning: unused variable 'r' [-Wunused-variable]
   24 |     double l = 0, r = 1e16;
      |                   ^
#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...