結果

問題 No.1715 Dinner 2
ユーザー kotatsugamekotatsugame
提出日時 2021-10-22 23:26:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 84,344 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 15:32:43
合計ジャッジ時間 1,984 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 5 ms
4,348 KB
testcase_33 AC 5 ms
4,348 KB
testcase_34 AC 6 ms
4,348 KB
testcase_35 AC 6 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int N,D;
main()
{
	cin>>N>>D;
	vector<pair<int,pair<int,int> > >PQ(N);
	for(int i=0;i<N;i++)
	{
		int p,q;cin>>p>>q;
		PQ[i]=make_pair(p,make_pair(p-q,i));
	}
	sort(PQ.begin(),PQ.end());
	int L=-1e9,R=1;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		int now=0;
		int id=0;
		multiset<pair<int,int> >S;
		int prv=-1;
		bool ok=true;
		for(int d=0;d<D;d++)
		{
			while(id<N&&PQ[id].first<=now-mid)
			{
				S.insert(PQ[id].second);
				id++;
			}
			while(id>0&&PQ[id-1].first>now-mid)
			{
				id--;
				S.erase(S.find(PQ[id].second));
			}
			if(S.empty())
			{
				ok=false;
				break;
			}
			auto it=S.begin();
			if(it->second!=prv)
			{
				now-=it->first;
				prv=it->second;
			}
			else
			{
				it++;
				if(it==S.end())
				{
					ok=false;
					break;
				}
				now-=it->first;
				prv=it->second;
			}
		}
		if(ok)L=mid;
		else R=mid;
	}
	cout<<L<<endl;
}
0