제출 #1109233

#제출 시각아이디문제언어결과실행 시간메모리
1109233dsyzHiring (IOI09_hiring)C++17
2 / 100
1582 ms44828 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define MAXN (1000005) int main(){ ios_base::sync_with_stdio(false);cin.tie(0); ll N; ld W; cin>>N>>W; ld S[N], Q[N]; //min salary, qualification pair<pair<ld,ld>,ld> arr[N]; for(ll i = 0;i < N;i++){ cin>>S[i]>>Q[i]; arr[i] = {{Q[i],S[i]},i}; } sort(arr,arr + N); //we can prove that the wages for all other workers will resolve around one worker's exact minimum salary S[i] vector<ll> ans; ld spent = 1e18; for(ll strictest = 0;strictest < N;strictest++){ ld budget = W; vector<ll> cur; if(arr[strictest].first.second > budget){ continue; } budget -= arr[strictest].first.second; cur.push_back(strictest + 1); for(ll i = 0;i < strictest;i++){ ld needed = (arr[i].first.first / arr[strictest].first.first) * arr[strictest].first.second; if(needed >= arr[i].first.second && budget >= needed){ budget -= needed; cur.push_back(i + 1); } } for(ll i = strictest + 1;i < N;i++){ ld needed = (arr[i].first.first / arr[strictest].first.first) * arr[strictest].first.second; if(needed >= arr[i].first.second && budget >= needed){ budget -= needed; cur.push_back(i + 1); } } if(cur.size() >= ans.size() && (W - budget) <= spent){ spent = W - budget; ans = cur; } } cout<<ans.size()<<'\n'; for(ll i = 0;i < ans.size();i++){ cout<<ans[i]<<'\n'; } }

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

hiring.cpp: In function 'int main()':
hiring.cpp:49:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(ll i = 0;i < ans.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...