結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 18 ms
6,944 KB
testcase_07 AC 22 ms
6,944 KB
testcase_08 AC 101 ms
12,032 KB
testcase_09 AC 26 ms
6,940 KB
testcase_10 AC 158 ms
16,000 KB
testcase_11 AC 154 ms
16,000 KB
testcase_12 AC 161 ms
16,000 KB
testcase_13 WA -
testcase_14 WA -
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)/nw << endl;
      return 0;
    }
    pres += (x.first-prev)*nw;
    nw += x.second;
    prev = x.first;
  }
}
0