結果

問題 No.817 Coin donation
ユーザー CleyLCleyL
提出日時 2022-12-30 17:01:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 85,508 KB
実行使用メモリ 15,972 KB
最終ジャッジ日時 2023-08-16 22:51:29
合計ジャッジ時間 3,034 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 21 ms
4,984 KB
testcase_07 AC 26 ms
5,452 KB
testcase_08 AC 141 ms
12,024 KB
testcase_09 AC 31 ms
5,912 KB
testcase_10 AC 220 ms
15,856 KB
testcase_11 AC 223 ms
15,972 KB
testcase_12 AC 221 ms
15,860 KB
testcase_13 WA -
testcase_14 WA -
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)/nw << endl;
      return 0;
    }
    pres += (x.first-prev)*nw;
    nw += x.second;
    prev = x.first;
  }
}
0