結果

問題 No.2424 Josouzai
ユーザー kt_soupkt_soup
提出日時 2023-08-18 21:09:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 75,088 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-05-06 02:44:58
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 28 ms
5,376 KB
testcase_05 AC 93 ms
6,400 KB
testcase_06 AC 90 ms
6,400 KB
testcase_07 AC 89 ms
6,528 KB
testcase_08 AC 94 ms
6,528 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 62 ms
6,016 KB
testcase_12 AC 47 ms
5,376 KB
testcase_13 AC 30 ms
5,376 KB
testcase_14 AC 51 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 82 ms
5,888 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 26 ms
5,376 KB
testcase_19 AC 44 ms
5,376 KB
testcase_20 AC 83 ms
6,144 KB
testcase_21 AC 65 ms
5,376 KB
testcase_22 AC 29 ms
5,376 KB
testcase_23 AC 35 ms
5,376 KB
testcase_24 AC 17 ms
5,376 KB
testcase_25 AC 88 ms
6,144 KB
testcase_26 AC 65 ms
5,376 KB
testcase_27 AC 94 ms
6,272 KB
testcase_28 AC 80 ms
5,760 KB
testcase_29 AC 73 ms
5,504 KB
testcase_30 AC 19 ms
5,376 KB
testcase_31 AC 44 ms
5,376 KB
testcase_32 AC 92 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<long long> A(N),s(N+1,0);
  for(int i=0;i<N;i++)cin >> A[i];
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++)s[i+1] = s[i] + A[i];
  int i = 1;
  for(;i<=N && s[i]<=K;i++);
  cout << i-1 << ' ' << K-s[i-1] << endl;
}
0