結果

問題 No.54 Happy Hallowe'en
ユーザー goodbatongoodbaton
提出日時 2015-07-30 19:30:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 924 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 77,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 16:42:08
合計ジャッジ時間 1,421 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 12 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 34 ms
5,376 KB
testcase_09 AC 43 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 42 ms
5,376 KB
testcase_13 AC 42 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%d%d",&v,&t);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000003
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 10000

int n;
int v,t;
pair<int,pair<int,int> > vt[SIZE];
bool dp[SIZE*2+10];

int main(){
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&v,&t);
        
        vt[i] = {v+t,{v,t}};
    }
    
    sort(vt,vt+n);
    
    dp[0] = true;
    
    for(int i=0;i<n;i++){
        
        for(int j=vt[i].second.second-1;j>=0;j--){
            if(dp[j])
                dp[j+vt[i].second.first]=true;
        }
    }
    
    for(int i=SIZE*2+19;i>=0;i--){
        if(dp[i]){
            printf("%d\n",i);
            break;
        }
    }
    
}
0