結果

問題 No.2424 Josouzai
ユーザー gemygemy
提出日時 2023-11-22 22:51:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 208,116 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-22 22:51:57
合計ジャッジ時間 8,343 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 28 ms
6,676 KB
testcase_05 AC 98 ms
6,676 KB
testcase_06 AC 92 ms
6,676 KB
testcase_07 AC 93 ms
6,676 KB
testcase_08 AC 98 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 24 ms
6,676 KB
testcase_11 AC 66 ms
6,676 KB
testcase_12 AC 49 ms
6,676 KB
testcase_13 AC 30 ms
6,676 KB
testcase_14 AC 53 ms
6,676 KB
testcase_15 AC 9 ms
6,676 KB
testcase_16 AC 86 ms
6,676 KB
testcase_17 AC 23 ms
6,676 KB
testcase_18 AC 27 ms
6,676 KB
testcase_19 AC 46 ms
6,676 KB
testcase_20 AC 86 ms
6,676 KB
testcase_21 AC 66 ms
6,676 KB
testcase_22 AC 30 ms
6,676 KB
testcase_23 AC 37 ms
6,676 KB
testcase_24 AC 17 ms
6,676 KB
testcase_25 AC 92 ms
6,676 KB
testcase_26 AC 66 ms
6,676 KB
testcase_27 AC 95 ms
6,676 KB
testcase_28 AC 81 ms
6,676 KB
testcase_29 AC 73 ms
6,676 KB
testcase_30 AC 18 ms
6,676 KB
testcase_31 AC 43 ms
6,676 KB
testcase_32 AC 93 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
    // Input
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    // Calculation
    sort(A.begin(), A.end());
    vector<long long> AA(N+2);
    AA[N+1] = 2'000'000'000;
    for (int i = 1; i <= N; ++i) AA[i] = AA[i-1] + A[i-1];

    // Output
    for (int i = 0; i < N+2; ++i) {
        if (AA[i] <= K && K < AA[i+1]) {
            cout << i << ' ' << K - AA[i] << endl;
            return 0;
        }
    }
}
0