結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
![]() |
提出日時 | 2020-05-08 21:27:39 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 30,592 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 23:46:16 |
合計ジャッジ時間 | 833 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 3 |
ソースコード
#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; }