結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2016-06-11 17:08:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 818 bytes |
| コンパイル時間 | 1,613 ms |
| コンパイル使用メモリ | 172,152 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-10-09 12:55:08 |
| 合計ジャッジ時間 | 3,326 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
pair<int, int> VT[10101];
bool dp[2][10101];
bool comp(pair<int, int> a, pair<int, int> b)
{
return a.second < b.second;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
while (cin >> N)
{
rep(i, 0, N)
{
int v, t; cin >> v >> t;
VT[i] = make_pair(v, t);
}
sort(VT, VT + N, comp);
rep(i, 0, 2) rep(j, 0, 10101) dp[i][j] = false;
dp[0][0] = true;
int ans = 0;
rep(i, 0, N)
{
int ii = i + 1;
rep(j, 0, 10101) dp[ii % 2][j] = false;
rep(j, 0, 10101) if (dp[i % 2][j])
{
dp[ii % 2][j] = true;
if (j < VT[i].second)
{
int jj = j + VT[i].first;
ans = max(ans, jj);
if(jj < 10000) dp[ii % 2][jj] = true;
}
}
}
cout << ans << endl;
}
}
はまやんはまやん