結果
| 問題 | No.817 Coin donation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-19 23:10:00 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 464 bytes |
| 記録 | |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 90,112 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-11 09:30:19 |
| 合計ジャッジ時間 | 2,014 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}