結果

問題 No.3758 Fan Meeting
コンテスト
ユーザー ei13333333
提出日時 2026-10-09 16:12:15
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,175 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,179 ms
コンパイル使用メモリ 362,120 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-10-09 20:56:26
合計ジャッジ時間 5,524 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, n, m) for (int i = n; i < (int)m; ++i)
#define REP(i, n) FOR(i, 0, n)
#define REP_1(i, n) for (int i = 1; i <= (int)n; ++i)
#define RFOR(i, n, m) for (int i = (int)n - 1; i >= (int)m; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREP_1(i, n) for (int i = (int)n; i >= 1; --i)

#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define SIZE(v) (int)v.size()
#define EMPTY(v) v.empty()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(RALL(v))
#define REVERSE(v) reverse(ALL(v))
#define UNIQUE(v) (SORT(v), v.erase(unique(ALL(v)), v.end()))

#define PB push_back
#define EB emplace_back
#define MP make_pair

#define YES() cout << "YES\n"
#define NO() cout << "NO\n"
#define Yes() cout << "Yes\n"
#define No() cout << "No\n"
#define YESNO(cond) cout << ((cond) ? "YES" : "NO") << '\n'
#define YesNo(cond) cout << ((cond) ? "Yes" : "No") << '\n'

#define IN(x, a, b) ((a) <= (x) && (x) < (b))
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))

#define FASTIO()                                                               \
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define PRECISION(n) cout << fixed << setprecision(n)

using P = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using max_queue = priority_queue<T>;

constexpr ll INF = 1000000000;
constexpr ll INFL = (ll)1000000000000001000LL;
constexpr ll MOD = 998244353;
constexpr ld PI = 3.141592653589793238462643383279;
constexpr ld EPS = 1e-9;

void solve() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    RSORT(a);
    int ng = 0, ok = INF - 1;
    while (ok - ng > 1) {
        int t = (ok + ng) / 2;
        int rem = s;
        for (int i = 0; i < n; i += t) {
            if (a[i] <= t) break;
            rem -= a[i];
        }
        if (rem > 0) ok = t;
        else ng = t;
    }
    cout << ok << endl;
}

int main() {
    FASTIO();
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
0