結果

問題 No.2424 Josouzai
ユーザー トミートミー
提出日時 2023-12-16 15:32:51
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-16 15:32:54
合計ジャッジ時間 2,664 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,676 KB
testcase_01 AC 0 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 14 ms
6,676 KB
testcase_05 AC 51 ms
6,676 KB
testcase_06 AC 47 ms
6,676 KB
testcase_07 AC 46 ms
6,676 KB
testcase_08 AC 53 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 10 ms
6,676 KB
testcase_11 AC 27 ms
6,676 KB
testcase_12 AC 19 ms
6,676 KB
testcase_13 AC 14 ms
6,676 KB
testcase_14 AC 25 ms
6,676 KB
testcase_15 AC 5 ms
6,676 KB
testcase_16 AC 41 ms
6,676 KB
testcase_17 AC 10 ms
6,676 KB
testcase_18 AC 12 ms
6,676 KB
testcase_19 AC 22 ms
6,676 KB
testcase_20 AC 42 ms
6,676 KB
testcase_21 AC 32 ms
6,676 KB
testcase_22 AC 14 ms
6,676 KB
testcase_23 AC 17 ms
6,676 KB
testcase_24 AC 8 ms
6,676 KB
testcase_25 AC 45 ms
6,676 KB
testcase_26 AC 31 ms
6,676 KB
testcase_27 AC 47 ms
6,676 KB
testcase_28 AC 39 ms
6,676 KB
testcase_29 AC 38 ms
6,676 KB
testcase_30 AC 10 ms
6,676 KB
testcase_31 AC 21 ms
6,676 KB
testcase_32 AC 46 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int n,k,a[200000];
	int i,m,cnt=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),compare_int);
	for(i=0;i<n;i++){
		if(k>=a[i]){
			k-=a[i];
			cnt++;
		}
	}
	printf("%d %d",cnt,k);
}
0