제출 #433081

#제출 시각아이디문제언어결과실행 시간메모리
433081ly20Hiring (IOI09_hiring)C++17
60 / 100
1100 ms29152 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 512345; long long s[MAXN], q[MAXN]; int id[MAXN]; bool cmp(int a, int b) { return s[a] * q[b] < s[b] * q[a]; } int main() { int n; long long w; scanf("%d %lld", &n, &w); for(int i = 0; i < n; i++) { id[i] = i; scanf("%lld %lld", &s[i], &q[i]); } sort(id, id + n, cmp); set <pair <long long, int> > s1; int resp = -1, id1 = 0; long long sum = 0; for(int i = 0; i < n; i++) { //printf("oi\n"); int cur = id[i]; sum += q[cur]; long long mn = s[cur]; s1.insert(make_pair(q[cur],cur)); while(sum * mn > w * q[cur]) { sum -= (*(--s1.end())).first; s1.erase(--s1.end()); } //printf("%d %d\n", s1.size(), resp); if((int) s1.size() > resp) { //printf("oi\n"); resp = s1.size(); id1 = i; } } //printf("%d\n", resp); s1.clear(); sum = 0; for(int i = 0; i <= id1; i++) { int cur = id[i]; sum += q[cur]; long long mn = s[cur]; s1.insert(make_pair(q[cur],cur)); while(sum * mn > w * q[cur]) { sum -= (*(--s1.end())).first; s1.erase(--s1.end()); } } printf("%d\n", s1.size()); while(!s1.empty()) { printf("%d\n", (*s1.begin()).second + 1); s1.erase(s1.begin()); } return 0; }

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

hiring.cpp: In function 'int main()':
hiring.cpp:51:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   51 |     printf("%d\n", s1.size());
      |             ~^     ~~~~~~~~~
      |              |            |
      |              int          std::set<std::pair<long long int, int> >::size_type {aka long unsigned int}
      |             %ld
hiring.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %lld", &n, &w);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
hiring.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld %lld", &s[i], &q[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...