제출 #228677

#제출 시각아이디문제언어결과실행 시간메모리
228677osaaateiasavtnlHiring (IOI09_hiring)C++14
30 / 100
1595 ms24508 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcount #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC const int N = 5e5 + 7; int n, W; struct Chel { int s, q, i; } a[N]; bool comp(Chel a, Chel b) { //return (a.s/a.q) < (b.s/b.q); return a.s * b.q < b.s * a.q; } bool compq(int i, int j) { return a[i].q < a[j].q; } bool ls(ii a, ii b) { return a.f * b.s < b.f * a.s; } int posq[N]; bool used[N]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> W; for (int i = 0; i < n; ++i) { cin >> a[i].s >> a[i].q; a[i].i = i; } sort(a, a + n, comp); vector <ii> t; for (int i = 0; i < n; ++i) t.app(mp(a[i].q, i)); sort(all(t)); for (int i = 0; i < n; ++i) posq[t[i].s] = i + 1; int ans = 0; ii pay = {0, 1}; vector <int> who; for (int i = 0; i < n; ++i) { used[posq[i]] = 1; int sum = 0, k = 0; for (int j = 1; j <= n; ++j) { if (used[j]) { sum += t[j - 1].f; ++k; if (sum * a[i].s <= W * a[i].q) { ii np = mp(sum * a[i].s, a[i].q); if (k > ans || (k == ans && ls(np, pay))) { ans = k; pay = np; who = {}; for (int i = 1; i <= j; ++i) if (used[i]) who.app(t[i - 1].s); } } } } } cout << ans << endl; for (int e : who) cout << e + 1 << ' '; cout << endl; }
#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...