結果

問題 No.710 チーム戦
ユーザー tnakao0123
提出日時 2018-07-02 15:11:34
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 3,000 ms
コード長 1,278 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 85,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 01:27:07
合計ジャッジ時間 1,648 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:54:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |     scanf("%d%d", &as[i], &bs[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

/* -*- coding: utf-8 -*-
*
* 710.cc: No.710 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100;
const int MAX_A = 1000;
const int MAX_M = MAX_N * MAX_A;
const int INF = 1 << 30;
/* typedef */
/* global variables */
int as[MAX_N], bs[MAX_N];
int dp[MAX_M + 1];
/* subroutines */
inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }
/* main */
int main() {
int n;
scanf("%d", &n);
int m = 0, bsum = 0;
for (int i = 0; i < n; i++) {
scanf("%d%d", &as[i], &bs[i]);
m += min(as[i], bs[i]);
bsum += bs[i];
}
fill(dp, dp + m + 1, -1);
dp[0] = 0;
for (int i = 0; i < n; i++) {
int &ai = as[i], &bi = bs[i];
for (int j = m - ai; j >= 0; j--)
if (dp[j] >= 0) setmax(dp[j + ai], dp[j] + bi);
}
int mind = INF;
for (int a = 0; a <= m; a++)
setmin(mind, max(a, bsum - dp[a]));
printf("%d\n", mind);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0