結果

問題 No.617 Nafmo、買い出しに行く
ユーザー funakoshifunakoshi
提出日時 2019-09-02 13:50:59
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 742 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 29,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 17:05:56
合計ジャッジ時間 4,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int swap(const void* a, const void* b);
int main(void)
{
    int num,weight,maxweight=0,max=0;
    int weightlist[num];
    scanf("%d %d",&num,&weight);
    for(int i=0;i<num;i++)
    {
        scanf("%d",&weightlist[i]);
        max+=weightlist[i];
    }
    qsort(weightlist, num, sizeof(int), swap);
    for(int i=num;0<=i;i--)
    {        
        int val = maxweight+weightlist[i];
        if(val<weight)
        {
            if(max>val)
            {
                maxweight+=weightlist[i];
            }            
        }
    }
    printf("%d",maxweight);
}
int swap(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}
0