結果
問題 | No.817 Coin donation |
ユーザー |
![]() |
提出日時 | 2019-04-19 21:44:24 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 708 bytes |
コンパイル時間 | 1,360 ms |
使用メモリ | 4,728 KB |
最終ジャッジ日時 | 2022-11-22 08:08:13 |
合計ジャッジ時間 | 2,689 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
3,496 KB |
testcase_01 | AC | 1 ms
3,464 KB |
testcase_02 | AC | 1 ms
3,508 KB |
testcase_03 | AC | 1 ms
3,520 KB |
testcase_04 | AC | 1 ms
3,520 KB |
testcase_05 | AC | 3 ms
3,460 KB |
testcase_06 | AC | 10 ms
3,548 KB |
testcase_07 | AC | 13 ms
3,580 KB |
testcase_08 | AC | 49 ms
4,056 KB |
testcase_09 | AC | 15 ms
3,420 KB |
testcase_10 | AC | 72 ms
4,720 KB |
testcase_11 | AC | 72 ms
4,700 KB |
testcase_12 | AC | 73 ms
4,728 KB |
testcase_13 | AC | 1 ms
3,448 KB |
testcase_14 | AC | 1 ms
3,344 KB |
testcase_15 | AC | 2 ms
3,420 KB |
ソースコード
#include<bits/stdc++.h> #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) (v).begin(),(v).end() #define SZ(x) ((int)(x).size()) #define int long long using namespace std; typedef vector<int> vint; typedef pair<int,int> pint; int N,K; vint a,b; bool check(int x) {// x以下の数がK個数以上あるか int cnt=0; REP(i,N){ if(a[i]<=x and x<=b[i]) cnt+=x-a[i]+1; else if(b[i]<x) cnt+=b[i]-a[i]+1; } return cnt>=K; } signed main() { cin>>N>>K; a.resize(N); b.resize(N); REP(i,N) cin>>a[i]>>b[i]; int ng=0,ok=1e9; while(ok-ng>1){ int mid=(ok+ng)/2; if(check(mid)) ok=mid; else ng=mid; } cout<<ok<<endl; }