結果

問題 No.817 Coin donation
ユーザー kakulin_realkakulin_real
提出日時 2019-04-22 10:20:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 165,004 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 02:05:12
合計ジャッジ時間 3,392 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 14 ms
5,376 KB
testcase_07 AC 16 ms
5,376 KB
testcase_08 AC 61 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 89 ms
5,376 KB
testcase_11 AC 90 ms
5,376 KB
testcase_12 AC 89 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,k;
ll a[e5],b[e5];
map<ll,ll> m;
ll dp[e5];
ll ans;

int main(){
  cin >> n >> k;
  for(ll i = 0;i < n;i++) cin >> a[i] >> b[i];
  ll top = 1000000000;
  ll bottom = 0;
  while(top-bottom > 1){
    ll middle = (top+bottom)/2;
    ll mem = 0;
    for(ll i = 0;i < n;i++){
      if(a[i] > middle) continue;
      if(b[i] > middle) mem += middle-a[i]+1;
      else mem += b[i]-a[i]+1;
    }
    if(mem >= k) top = middle;
    else bottom = middle;
  }
  cout << top << endl;

}
0