Submission #3375849
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <numeric> #include <stack> #include <queue> #include <map> #include <set> #include <utility> #include <sstream> #include <complex> #include <fstream> #include <bitset> #include <time.h> #include <tuple> #include <iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef vector<ll> V; typedef complex<double> Point; #define PI acos(-1.0) #define EPS 1e-10 const ll INF = 1e16; const ll MOD = 1e9 + 7; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,N) for(int i=0;i<(N);i++) #define ALL(s) (s).begin(),(s).end() #define EQ(a,b) (abs((a)-(b))<EPS) #define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) ) #define fi first #define se second #define N_SIZE (1LL << 20) #define NIL -1 ll sq(ll num) { return num*num; } ll mod_pow(ll x, ll n) { if (n == 0)return 1; if (n == 1)return x%MOD; ll res = sq(mod_pow(x, n / 2)); res %= MOD; if (n % 2 == 1) { res *= x; res %= MOD; } return res; } ll mod_add(ll a, ll b) { return (a + b) % MOD; } ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; } ll mod_mul(ll a, ll b) { return a*b % MOD; } int n; vector<P> vp; ll dp[5001][5001]; int main(){ cin >> n; rep(i,n){ ll h,p; cin >> h >> p; vp.push_back(P(p,h)); } sort(ALL(vp)); rep(i,5001)rep(j,5001)dp[i][j] = INF; dp[0][0] = 0; rep(i,n){ ll p = vp[i].first; ll h = vp[i].second; rep(j,n+1){ if(dp[i][j] <= h)dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j] + p); if(i+1 < 5001)dp[i+1][j] = min(dp[i+1][j],dp[i][j]); } } ll ans = 0; rep(i,n+1)if(dp[n][i] != INF)ans = i; cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Zabuton |
User | jimmy |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1848 Byte |
Status | WA |
Exec Time | 98 ms |
Memory | 195840 KB |
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | sample-01.txt, sample-02.txt, sample-03.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, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 49 ms | 195584 KB |
01-02.txt | AC | 49 ms | 195584 KB |
01-03.txt | WA | 52 ms | 195712 KB |
01-04.txt | WA | 60 ms | 195712 KB |
01-05.txt | WA | 89 ms | 195840 KB |
01-06.txt | WA | 89 ms | 195840 KB |
01-07.txt | WA | 89 ms | 195840 KB |
01-08.txt | WA | 89 ms | 195840 KB |
01-09.txt | WA | 89 ms | 195840 KB |
01-10.txt | AC | 50 ms | 195584 KB |
01-11.txt | WA | 52 ms | 195712 KB |
01-12.txt | WA | 66 ms | 195712 KB |
01-13.txt | WA | 89 ms | 195840 KB |
01-14.txt | WA | 91 ms | 195840 KB |
01-15.txt | WA | 90 ms | 195840 KB |
01-16.txt | WA | 90 ms | 195840 KB |
01-17.txt | WA | 90 ms | 195840 KB |
01-18.txt | WA | 90 ms | 195840 KB |
01-19.txt | WA | 49 ms | 195584 KB |
01-20.txt | WA | 51 ms | 195712 KB |
01-21.txt | WA | 72 ms | 195712 KB |
01-22.txt | WA | 93 ms | 195840 KB |
01-23.txt | WA | 93 ms | 195840 KB |
01-24.txt | WA | 93 ms | 195840 KB |
01-25.txt | WA | 93 ms | 195840 KB |
01-26.txt | WA | 94 ms | 195840 KB |
01-27.txt | WA | 94 ms | 195840 KB |
01-28.txt | WA | 88 ms | 195840 KB |
01-29.txt | WA | 87 ms | 195840 KB |
01-30.txt | WA | 88 ms | 195840 KB |
01-31.txt | WA | 88 ms | 195840 KB |
01-32.txt | WA | 88 ms | 195840 KB |
01-33.txt | AC | 89 ms | 195840 KB |
01-34.txt | AC | 89 ms | 195840 KB |
01-35.txt | WA | 97 ms | 195840 KB |
01-36.txt | WA | 97 ms | 195840 KB |
01-37.txt | WA | 96 ms | 195840 KB |
01-38.txt | WA | 97 ms | 195840 KB |
01-39.txt | WA | 98 ms | 195840 KB |
01-40.txt | AC | 89 ms | 195840 KB |
sample-01.txt | AC | 50 ms | 195584 KB |
sample-02.txt | AC | 50 ms | 195584 KB |
sample-03.txt | AC | 50 ms | 195584 KB |