제출 #598796

#제출 시각아이디문제언어결과실행 시간메모리
598796denniskimLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
2 ms340 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second

ll n;
ll k;
pair< pair<ll, ll>, ll> a[1010], b[1010];
ld ans = INF;
ll chk[1010];

int main(void)
{
	scanf("%lld", &n);
	scanf("%lld", &k);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		scanf("%lld %lld", &a[i].fi.fi, &a[i].fi.se);
		
		a[i].se = i;
		b[i] = {{a[i].fi.se == -1 ? 10000000000 : a[i].fi.se, a[i].fi.fi}, i};
	}
	
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	
	for(ll i = 0 ; i <= k ; i++)
	{
		ld sum = 0;
		ll ppl = 1;
		ll cou = 0;
		
		for(ll j = 1 ; j <= i ; j++)
		{
			sum += (ld)b[j].fi.fi / (ld)ppl;
			ppl++;
			chk[b[j].se] = i + 1;
			cou++;
		}
		
		for(ll j = 1 ; cou < k ; j++)
		{
			if(chk[a[j].se] == i + 1)
				continue;
			
			sum += (ld)a[j].fi.fi / (ld)ppl;
			cou++;
		}
		
		ans = min(ans, sum);
	}
	
	printf("%.10Lf", ans);
	return 0;
}

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

Main.cpp: In function 'int main()':
Main.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%lld", &k);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%lld %lld", &a[i].fi.fi, &a[i].fi.se);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...