Submission #442967

#TimeUsernameProblemLanguageResultExecution timeMemory
442967dutchHiring (IOI09_hiring)C++17
100 / 100
559 ms21748 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define D double
 
int n, w, j, s;
array<double, 2> res, c;
 
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> w;
	array<double, 3> a[n];
	for(auto &i : a){
		cin >> i[0] >> i[1];
		i[0] = (w * i[1]) / -i[0];
		i[2] = ++j;
	}

	sort(a, a+n);
 
	priority_queue<int> q;
	priority_queue<array<int, 2>> r;
 
	for(auto &i : a){
		q.push(i[1]);
		s += i[1];
		while(s > -i[0]) s -= q.top(), q.pop();
		res = max(res, {(D)q.size(), s/i[0]});
	}
 
	vector<int> ans = {D(res[0])};
	s = 0;
	for(auto &i : a){
		r.push({i[1], i[2]});
		s += i[1];
		while(s > -i[0]) s -= r.top()[0], r.pop();
		if(res == (c = {(D)r.size(), s/i[0]})){
			while(!r.empty()) ans.push_back((D)r.top()[1]), r.pop();
			break;
		}
	}
 
	for(int i : ans) cout << i << '\n';
}

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:4:11: warning: narrowing conversion of 'res.std::array<double, 2>::operator[](0)' from 'std::array<double, 2>::value_type' {aka 'double'} to 'long long int' [-Wnarrowing]
    4 | #define D double
      |           ^
hiring.cpp:31:21: note: in expansion of macro 'D'
   31 |  vector<int> ans = {D(res[0])};
      |                     ^
hiring.cpp:4:11: warning: narrowing conversion of 'res.std::array<double, 2>::operator[](0)' from 'std::array<double, 2>::value_type' {aka 'double'} to 'long long int' [-Wnarrowing]
    4 | #define D double
      |           ^
hiring.cpp:31:21: note: in expansion of macro 'D'
   31 |  vector<int> ans = {D(res[0])};
      |                     ^
hiring.cpp:34:22: warning: narrowing conversion of '(& i)->std::array<double, 3>::operator[](1)' from 'std::array<double, 3>::value_type' {aka 'double'} to 'long long int' [-Wnarrowing]
   34 |   r.push({i[1], i[2]});
      |                      ^
hiring.cpp:34:22: warning: narrowing conversion of '(& i)->std::array<double, 3>::operator[](2)' from 'std::array<double, 3>::value_type' {aka 'double'} to 'long long int' [-Wnarrowing]
#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...