結果

問題 No.1046 Fruits Rush
コンテスト
ユーザー Maeda
提出日時 2025-03-11 11:48:00
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 467 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 134 ms
コンパイル使用メモリ 38,596 KB
最終ジャッジ日時 2026-02-22 13:13:12
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void){
	int n = 0 , k = 0;
	scanf("%d %d",&n,&k);
	int fresh[n];
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&fresh[i]);
	}
	for(int i = 0 ; i < n ; i++){
		for(int j = i ; j < n ; j++ ){
			if(fresh[i] < fresh[j]){
				int num = fresh[i];
				fresh[i] = fresh[j];
				fresh[j] = num;
			}
		}
	}
	int delicious = 0;
	for(int i = 0 ; i < k ; i++){
		if(fresh[i] <= 0){
			break;
		}
		delicious += fresh[i];
	}
	printf("%d",delicious);
}
0