結果

問題 No.817 Coin donation
ユーザー kotatsugamekotatsugame
提出日時 2019-04-19 23:10:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 75,484 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 11:56:46
合計ジャッジ時間 2,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 13 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 58 ms
4,348 KB
testcase_09 AC 19 ms
4,348 KB
testcase_10 AC 83 ms
4,348 KB
testcase_11 AC 84 ms
4,348 KB
testcase_12 AC 84 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,K;
vector<pair<int,int> >A;
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		int a,b;cin>>a>>b;
		A.push_back({a,b});
	}
	int L=0,R=1e9+114514;
	while(R-L>1)
	{
		int M=(L+R)/2;
		int now=K;
		for(int i=0;i<N;i++)
		{
			if(A[i].first<=M)
			{
				now-=min(M,A[i].second)-A[i].first+1;
				if(now<=0)break;
			}
		}
		if(now<=0)R=M;
		else L=M;
	}
	cout<<R<<endl;
}
0