結果

問題 No.3758 Fan Meeting
コンテスト
ユーザー tnakao0123
提出日時 2026-10-11 12:29:14
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 42 ms / 2,000 ms
+ 372µs
コード長 728 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 311 ms
コンパイル使用メモリ 80,516 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-11 12:29:27
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3758.cc:  No.3758 Fan Meeting - yukicoder
 */

#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 300000;

/* typedef */

using ll = long long;

/* global variables */

int as[MAX_N];

/* subroutines */

ll calc(int n, int t) {
  ll r = 0;
  for (int i = 0; i < n && as[i] > t; i += t) r += as[i];
  return r;
}

/* main */

int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  sort(as, as + n, greater<int>());

  int t0 = 0, t1 = as[0];
  while (t0 + 1 < t1) {
    int t = (t0 + t1) / 2;
    if (calc(n, t) < s) t1 = t;
    else t0 = t;
  }

  printf("%d\n", t1);
  
  return 0;
}
0