提出 #512645
ソースコード 拡げる
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<vector<PII> > VVPII;
typedef priority_queue<PII, vector<PII>, greater<PII> > PQPII;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};
//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(int argc, char const *argv[])
{
LL N, T;
cin >> N >> T;
VI A(N), B(N);
REP(i, N){
cin >> A[i] >> B[i];
}
vector<vector<LL>> dp(N + 1, vector<LL>(N, -1));
dp[0][0] = 0;
REP(i, N){
REP(j, i + 1){
if(dp[i][j] < 0) continue;
// 写さなかった場合
if(dp[i + 1][j] >= 0){
dp[i + 1][j] = min(dp[i][j] + A[i], dp[i + 1][j]);
}else{
dp[i + 1][j] = dp[i][j] + A[i];
}
// 写した場合
if(dp[i + 1][j + 1] >= 0){
dp[i + 1][j + 1] = min(dp[i][j] + B[i], dp[i + 1][j + 1]);
}else{
dp[i + 1][j + 1] = dp[i][j] + B[i];
}
}
}
int res = -1;
REP(i, N){
if(dp[N][i] <= T){
res = i;
break;
}
}
cout << res << endl;
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
C - 8月31日 |
| ユーザ |
xyz |
| 言語 |
C++11 (GCC 4.9.2) |
| 得点 |
0 |
| コード長 |
3033 Byte |
| 結果 |
WA |
| 実行時間 |
2122 ms |
| メモリ |
1048576 KiB |
ジャッジ結果
| セット名 |
Sample |
Dataset1 |
Dataset2 |
| 得点 / 配点 |
0 / 0 |
0 / 30 |
0 / 70 |
| 結果 |
|
| AC |
× 3 |
| WA |
× 1 |
| TLE |
× 1 |
| MLE |
× 9 |
| RE |
× 1 |
|
| AC |
× 9 |
| WA |
× 2 |
| TLE |
× 3 |
| MLE |
× 19 |
| RE |
× 3 |
|
| セット名 |
テストケース |
| Sample |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt |
| Dataset1 |
sample-01, sample-02, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt |
| Dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01-01.txt |
WA |
27 ms |
800 KiB |
| 01-02.txt |
AC |
28 ms |
760 KiB |
| 01-03.txt |
RE |
277 ms |
844 KiB |
| 01-04.txt |
AC |
26 ms |
916 KiB |
| 01-05.txt |
AC |
192 ms |
71196 KiB |
| 01-06.txt |
MLE |
1970 ms |
1048576 KiB |
| 01-07.txt |
MLE |
1901 ms |
1048576 KiB |
| 01-08.txt |
MLE |
1918 ms |
1048576 KiB |
| 01-09.txt |
MLE |
1866 ms |
1048576 KiB |
| 01-10.txt |
MLE |
1901 ms |
1048576 KiB |
| 01-11.txt |
MLE |
1915 ms |
1048576 KiB |
| 01-12.txt |
MLE |
1902 ms |
1048576 KiB |
| 01-13.txt |
MLE |
1953 ms |
1048576 KiB |
| 01-14.txt |
MLE |
1904 ms |
1048576 KiB |
| 01-15.txt |
TLE |
2108 ms |
1048576 KiB |
| 02-01.txt |
WA |
27 ms |
796 KiB |
| 02-02.txt |
AC |
26 ms |
924 KiB |
| 02-03.txt |
AC |
27 ms |
792 KiB |
| 02-04.txt |
AC |
45 ms |
8612 KiB |
| 02-05.txt |
MLE |
1946 ms |
782632 KiB |
| 02-06.txt |
MLE |
1949 ms |
1048576 KiB |
| 02-07.txt |
MLE |
1924 ms |
1048576 KiB |
| 02-08.txt |
MLE |
1927 ms |
1048576 KiB |
| 02-09.txt |
MLE |
1919 ms |
1048576 KiB |
| 02-10.txt |
MLE |
1934 ms |
1048576 KiB |
| 02-11.txt |
TLE |
2043 ms |
1048576 KiB |
| 02-12.txt |
MLE |
1942 ms |
1048576 KiB |
| 02-13.txt |
MLE |
1926 ms |
1048576 KiB |
| 02-14.txt |
TLE |
2122 ms |
1048576 KiB |
| 02-15.txt |
MLE |
1966 ms |
1048576 KiB |
| 02-16.txt |
MLE |
1922 ms |
1048576 KiB |
| sample-01.txt |
RE |
271 ms |
812 KiB |
| sample-02.txt |
AC |
26 ms |
916 KiB |
| sample-03.txt |
AC |
26 ms |
732 KiB |
| sample-04.txt |
RE |
277 ms |
820 KiB |
| sample-05.txt |
AC |
26 ms |
792 KiB |