結果

問題 No.710 チーム戦
ユーザー akakimidoriakakimidori
提出日時 2018-08-02 05:42:56
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 3,000 ms
コード長 716 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 23,580 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 20:58:22
合計ジャッジ時間 1,238 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 4 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 5 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 7 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 0 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:13:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c:23:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |     scanf("%d%d",&a,&b);
      |     ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  const int m=n*1000;
  int *dp=(int *)malloc(sizeof(int)*(m+1));
  const int inf=1000*100+1;
  int i;
  for(i=0;i<=m;i++) dp[i]=inf;
  dp[0]=0;
  int sum=0;
  for(i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    int j;
    for(j=sum;j>=0;j--){
      if(dp[j]==inf) continue;
      dp[j+a]=MIN(dp[j+a],dp[j]);
      dp[j]+=b;
    }
    sum+=a;
  }
  int min=inf;
  for(i=0;i<=sum;i++) min=MIN(min,MAX(i,dp[i]));
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}
0