結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-07-30 19:30:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 924 bytes |
| コンパイル時間 | 678 ms |
| コンパイル使用メモリ | 76,940 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 17:13:14 |
| 合計ジャッジ時間 | 1,667 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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;
}
}
}
goodbaton