Submission #490717

#TimeUsernameProblemLanguageResultExecution timeMemory
490717ntabc05101Hiring (IOI09_hiring)C++14
60 / 100
317 ms15032 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "" int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else { if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } } cin.tie(0)->sync_with_stdio(0); int n; long long w; cin >> n >> w; struct Sal { int s, q; double r; int idx; bool operator < (const Sal &other) { return r < other.r; } }; Sal a[n]; for (int i = 0; i < n; i++) { cin >> a[i].s >> a[i].q; a[i].r = 1. * a[i].s / a[i].q; a[i].idx = i; } sort(a, a + n); long long cur = 0; priority_queue< array<int, 2> > pq; int res = 0; int j = 0; for (int i = 0; i < n; i++) { pq.push({a[i].q, 0}); cur += a[i].q; while (a[i].r * cur > w) { cur -= pq.top()[0]; pq.pop(); } if (res < (int)pq.size()) { res = pq.size(); j = i; } } cout << res << "\n"; while (!pq.empty()) { pq.pop(); } cur = 0; for (int i = 0; i <= j; i++) { pq.push({a[i].q, a[i].idx}); cur += a[i].q; while (a[i].r * cur > w) { cur -= pq.top()[0]; pq.pop(); } } while (!pq.empty()) { cout << 1 + pq.top()[1] << "\n"; pq.pop(); } return 0; }

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
hiring.cpp:9:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   freopen(taskname".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hiring.cpp:13:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |    freopen(taskname".in", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
hiring.cpp:14:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |    freopen(taskname".out", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...