結果

問題 No.1715 Dinner 2
ユーザー publflpublfl
提出日時 2021-10-22 21:45:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,198 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 50,364 KB
実行使用メモリ 7,136 KB
最終ジャッジ日時 2023-10-24 12:47:52
合計ジャッジ時間 1,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,104 KB
testcase_01 AC 4 ms
7,104 KB
testcase_02 AC 3 ms
7,104 KB
testcase_03 AC 3 ms
7,104 KB
testcase_04 AC 3 ms
7,104 KB
testcase_05 AC 3 ms
7,104 KB
testcase_06 AC 3 ms
7,104 KB
testcase_07 AC 3 ms
7,104 KB
testcase_08 AC 3 ms
7,104 KB
testcase_09 AC 4 ms
7,104 KB
testcase_10 AC 3 ms
7,104 KB
testcase_11 AC 4 ms
7,132 KB
testcase_12 AC 4 ms
7,132 KB
testcase_13 AC 4 ms
7,136 KB
testcase_14 AC 4 ms
7,132 KB
testcase_15 AC 4 ms
7,132 KB
testcase_16 AC 4 ms
7,128 KB
testcase_17 AC 4 ms
7,124 KB
testcase_18 AC 3 ms
7,104 KB
testcase_19 AC 3 ms
7,104 KB
testcase_20 AC 3 ms
7,104 KB
testcase_21 AC 3 ms
7,104 KB
testcase_22 AC 3 ms
7,104 KB
testcase_23 AC 3 ms
7,108 KB
testcase_24 AC 4 ms
7,104 KB
testcase_25 AC 4 ms
7,108 KB
testcase_26 AC 4 ms
7,108 KB
testcase_27 AC 3 ms
7,108 KB
testcase_28 AC 4 ms
7,108 KB
testcase_29 AC 4 ms
7,108 KB
testcase_30 AC 3 ms
7,108 KB
testcase_31 AC 3 ms
7,108 KB
testcase_32 AC 4 ms
7,136 KB
testcase_33 AC 3 ms
7,136 KB
testcase_34 AC 4 ms
7,136 KB
testcase_35 AC 4 ms
7,136 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
#define MIN -1234567890

std::vector< std::pair<int,int> > V[100010];
std::pair<int,int> x[100010],y[100010];

int main()
{
	
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(std::make_pair(d-c,i));
	}
	
	std::pair<int,int> max1 = std::make_pair(MIN,0);
	std::pair<int,int> max2 = max1;
	
	for(int i=0;i<=100000;i++)
	{
		for(int j=0;j<V[i].size();j++)
		{
			if(max1.first <=V[i][j].first) max2 = max1, max1 = V[i][j];
			else if(max2.first <= V[i][j].first) max2 = V[i][j];
		}
		
		x[i] = max1, y[i] = max2;
	}
	
	
	long long int min = MIN, max = 0;
	long long int ans = MIN;
	while(min<=max)
	{
		long long int h = (min+max)/2;
		
		int prev = -1;
		long long int s = -h;
		for(int i=1;i<=b;i++)
		{
			long long int t = s<100000?s:100000;
			if(x[t].second==0)
			{
				max = h-1;
				goto u;
			}
			else if(prev==x[t].second)
			{
				if(y[t].second==0)
				{
					max = h-1;
					goto u;
				}
				else
				{
					s += (y[t].first);
					prev = y[t].second;
				}
			}
			else
			{
				s += (x[t].first);
				prev = x[t].second;
			}
		}
		ans = h;
		min = h+1;
		u:;
	}
	printf("%lld",ans);
}
0