제출 #490718

#제출 시각아이디문제언어결과실행 시간메모리
490718ntabc05101Hiring (IOI09_hiring)C++14
59 / 100
302 ms15160 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; pair<int, double> res = {0, -w}; int j = -1; 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 < make_pair((int)pq.size(), a[i].r * cur)) { res = {pq.size(), a[i].r * cur}; j = i; } } cout << res.first << "\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; }

컴파일 시 표준 에러 (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...