結果

問題 No.1046 Fruits Rush
ユーザー MiKo_IZUMIMiKo_IZUMI
提出日時 2020-05-08 21:27:39
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 29,052 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-17 01:34:40
合計ジャッジ時間 946 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int hikaku(const void *n1,const void *n2)
{
    return -*(int*)n1+*(int*)n2;
}



int main()
{

    int n,k,ans=0;
    scanf("%d %d",&n,&k);
    int  a[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    qsort(a,n,sizeof(int),hikaku);

    int flag=0,f=0;
    while(a[flag]>0&&f<k)
    {
        ans=ans+a[flag];
        flag=flag+1;
        f=f+1;
    }


    printf("%d\n",ans);
    
    return 0;
}
0