結果
| 問題 |
No.617 Nafmo、買い出しに行く
|
| コンテスト | |
| ユーザー |
funakoshi
|
| 提出日時 | 2019-09-02 14:10:18 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 842 bytes |
| コンパイル時間 | 287 ms |
| コンパイル使用メモリ | 31,744 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-15 07:17:03 |
| 合計ジャッジ時間 | 1,020 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 WA * 13 |
ソースコード
#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;
scanf("%d %d",&num,&weight);
int weightlist[1000]={0};
for(int i=0;i<num;i++)
{
scanf("%d",&weightlist[i]);
if(weightlist[i]<weight)
{
maxweight=weightlist[i];
}
max+=weightlist[i];
}
qsort(weightlist, num, sizeof(int), swap);
for(int i=0;i<num-1;i++)
{
int val = weightlist[i];
for(int j=i+1;j<num;j++)
{
if(val+weightlist[j]<=weight)
{
maxweight=val+weightlist[j];
}
}
}
printf("%d",maxweight);
}
int swap(const void* a, const void* b)
{
return *(int*)a - *(int*)b;
}
funakoshi