結果
問題 | No.817 Coin donation |
ユーザー |
![]() |
提出日時 | 2023-03-24 03:29:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 2,000 ms |
コード長 | 847 bytes |
コンパイル時間 | 4,263 ms |
コンパイル使用メモリ | 251,912 KB |
最終ジャッジ日時 | 2025-02-11 16:41:14 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=144499999994; ll mod=1000000007; int main(){ ll n,k; cin >> n >> k; vector<ll>a(n),b(n); for (ll i = 0; i < n; i++) { cin >> a[i] >> b[i]; } ll left=0,right=inf; while (right-left>1) { ll mid=(right+left)/2; ll x=0; for (ll i = 0; i < n; i++) { if (mid>=a[i]) { if (mid>=b[i]) { x+=b[i]-a[i]+1; }else{ x+=mid-a[i]+1; } } } if (x<k) { left=mid; }else{ right=mid; } } cout << right << endl; }