結果
| 問題 |
No.817 Coin donation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-19 23:10:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 86 ms / 2,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 673 ms |
| コンパイル使用メモリ | 75,672 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-23 04:16:25 |
| 合計ジャッジ時間 | 1,787 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#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;
}