結果

問題 No.817 Coin donation
ユーザー CleyLCleyL
提出日時 2022-12-30 17:03:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 85,920 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-05-04 06:15:52
合計ジャッジ時間 2,082 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 18 ms
6,940 KB
testcase_07 AC 24 ms
6,944 KB
testcase_08 AC 108 ms
11,904 KB
testcase_09 AC 28 ms
6,940 KB
testcase_10 AC 176 ms
16,000 KB
testcase_11 AC 167 ms
16,000 KB
testcase_12 AC 166 ms
16,000 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(){
  long long n,k;cin>>n>>k;
  map<int,long long> A;
  for(int i = 0; n > i; i++){
    int a,b;cin>>a>>b;
    A[a]++;
    A[b+1]--;
  }
  int prev = -1;
  long long nw = 0;
  long long pres = 0;
  for(auto x: A){
    if((x.first-prev)*nw + pres >= k){
      cout << prev+(k-pres-1)/nw << endl;
      return 0;
    }
    pres += (x.first-prev)*nw;
    nw += x.second;
    prev = x.first;
  }
}
0