Submission #733690

#TimeUsernameProblemLanguageResultExecution timeMemory
733690penguin133Hiring (IOI09_hiring)C++17
52 / 100
1581 ms18120 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, w; pii A[500005]; bool cmp(pii a, pii b){ return ((long double)a.fi / (long double)a.se.fi) < ((long double)b.fi / (long double)b.se.fi); } void solve(){ cin >> n >> w; for(int i=1;i<=n;i++)cin >> A[i].fi >> A[i].se.fi, A[i].se.se = i; sort(A+1, A+n+1, cmp); vector <pi> v; pair<int, long double> ans = {0, 0.0L}; vector <int> fin; for(int i=1;i<=n;i++){ int x = w * A[i].se.fi / A[i].fi; x -= A[i].se.fi; vector <int> tmp = {A[i].se.se}; for(auto [j, k] : v){ if(x >= j)x -= j, tmp.push_back(k); } v.push_back({A[i].se.fi, A[i].se.se}); sort(v.begin(), v.end()); int used = w * A[i].se.fi / A[i].fi - x; long double brub = (long double)(used * A[i].fi) / A[i].se.fi; if((int)tmp.size() > ans.fi || ((int)tmp.size() == ans.fi && ans.se < -brub))ans = {(int)tmp.size(), -brub}, fin = tmp; } cout << fin.size() << '\n'; for(auto i : fin)cout << i << '\n'; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

hiring.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main(){
      | ^~~~
#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...