結果

問題 No.54 Happy Hallowe'en
ユーザー ytftytft
提出日時 2022-11-06 02:50:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 667 bytes
コンパイル時間 4,319 ms
コンパイル使用メモリ 247,396 KB
実行使用メモリ 785,116 KB
最終ジャッジ日時 2023-09-27 01:26:28
合計ジャッジ時間 9,322 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 148 ms
218,352 KB
testcase_05 AC 277 ms
318,576 KB
testcase_06 AC 359 ms
421,220 KB
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 MLE -
testcase_13 MLE -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 3 ms
5,416 KB
testcase_17 AC 3 ms
5,568 KB
testcase_18 AC 2 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void solve(int N){
	int rang=20000,V[N],T[N],ord[N],dp[N+1][rang],ans=0;
    for(int i=0;i<N;++i){
    	scanf("%d%d",V+i,T+i);
    	ord[i]=i;
    }
    sort(ord,ord+N,[&V,&T](int a,int b){
    	return V[a]+T[a]<V[b]+T[b];
    });
    for(int i=0;i<=N;++i){
    	for(int j=0;j<rang;++j){
    		dp[i][j]=0;
    	}
    }
    dp[0][0]=1;
    for(int i=0;i<N;++i){
    	for(int j=0;j<rang;++j)dp[i+1][j]|=dp[i][j];
    	for(int j=0;j<T[ord[i]];++j)dp[i+1][j+V[ord[i]]]|=dp[i][j];
    }
    for(int i=0;i<rang;++i){
    	if(dp[N][i])ans=i;
    }
    printf("%d\n",ans);
}
int main(){
	int N;
    scanf("%d",&N);
    solve(N);
}
0