結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2016-02-16 05:12:57 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 1,324 ms |
コンパイル使用メモリ | 164,484 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 17:14:32 |
合計ジャッジ時間 | 2,160 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)#define all(n) (n).begin(),(n).end()typedef long long ll;typedef vector<int> Vi;typedef vector<Vi> VVi;typedef pair<long long,long long> Pii;typedef vector<Pii> VPii;bool dp[20010];int main(){int N;cin >> N;vector< pair<int,int> > v;for(int i = 0 ; i < N ; i++){int V,T;cin >> V >> T;v.push_back({T+V,V});}sort(v.begin(),v.end());dp[0] = 1;for(auto i : v ){int V = i.second;int T = i.first - V;for(int j = T - 1 ; j >= 0 ; j--)dp[j+V] |= dp[j];}for(int i = 20000 ; i >= 0 ; i--)if( dp[i] ){cout << i << endl;return 0;}}