Submission #433085

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4330852021-06-18 20:33:28ly20Hiring (IOI09_hiring)C++17
59 / 100
1077 ms24868 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;
long long ccur = 0, cst = 0, qt = 1;
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());
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:55: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=]
   55 |     printf("%d\n", s1.size());
      |             ~^     ~~~~~~~~~
      |              |            |
      |              int          std::set<std::pair<long long int, int> >::size_type {aka long unsigned int}
      |             %ld
hiring.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i = 0; i < rsp.size(); i++) {
      |                    ~~^~~~~~~~~~~~
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...