結果

問題 No.817 Coin donation
ユーザー CleyLCleyL
提出日時 2022-12-30 17:03:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 85,712 KB
実行使用メモリ 15,864 KB
最終ジャッジ日時 2023-08-16 22:53:24
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 18 ms
4,960 KB
testcase_07 AC 24 ms
5,428 KB
testcase_08 AC 110 ms
11,992 KB
testcase_09 AC 28 ms
5,848 KB
testcase_10 AC 169 ms
15,836 KB
testcase_11 AC 167 ms
15,864 KB
testcase_12 AC 175 ms
15,840 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 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