# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
364349 | 2021-02-09T02:34:01 Z | Killer2501 | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 1 ms | 492 KB |
#include <bits/stdc++.h> #define pb push_back #define task "sequence" #define pll pair<ll, ll> #define pii pair<vector<ll>, ll> #define fi first #define se second using ll = long long; const long long mod = 1e15+7; const ll mod1 = 1e9+1; const ll N = 205; const int base = 350; using ull = unsigned long long; using namespace std; string s, ss; ll n, m, t, k, T, cnt, tong, a[N], c[N], b[N], dp[N][N][N][2]; vector<ll> adj[N], kq; pll p[N]; int ans; void Min(ll& x, ll y) { if(x > y)x = y; } void sol() { cin >> n >> m; for(int i = 1; i <= n; i ++) { cin >> a[i]; b[i] = m - a[i]; //cout << b[i] <<" "; } for(int i = 1; i <= n; i ++)b[i] = m - a[n-i+1]; //cout << '\n'; c[0] = c[n+1] = -1; for(int i = 1; i <= n; i ++)cin >> c[i]; for(int i = 0; i <= n; i ++) for(int j = 0; j <= n; j ++) for(int l = 0; l <= n; l ++)dp[i][j][l][0] = dp[i][j][l][1] = mod; dp[0][0][0][0] = dp[0][0][0][1] = 0; for(int i = 0; i <= n; i ++) { for(int j = 0; j <= n; j ++) { for(int l = 0; l <= n; l ++) { if(dp[i][j][l][0] != mod) { ans = max(ans, l); if(i < n) { k = dp[i][j][l][0] + a[i+1] - a[i]; Min(dp[i+1][j][l+(k<=c[i+1])][0], k); } if(j < n) { k = dp[i][j][l][0] + b[j+1] + a[i]; Min(dp[i][j+1][l+(k<=c[n-j])][1], k); } } if(dp[i][j][l][1] != mod) { ans = max(ans, l); if(i < n) { k = dp[i][j][l][1] + b[j] + a[i+1]; Min(dp[i+1][j][l+(k<=c[i+1])][0], k); } if(j < n) { k = dp[i][j][l][1] + b[j+1] - b[j]; Min(dp[i][j+1][l+(k<=c[n-j])][1], k); } } cout << i <<" "<<j<<" "<<l<<" "<<dp[i][j][l][0]<<" "<<dp[i][j][l][1] << '\n'; } } } cout << ans; } int main() { if(fopen(task".in", "r")){ freopen(task".in", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest; ntest = 1; //cin >> ntest; //cout << (1<<30) << '\n'; while(ntest -- > 0) sol(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |