Submission #361301

#TimeUsernameProblemLanguageResultExecution timeMemory
361301RyoPham도장 모으기 (JOI14_stamps)C++14
100 / 100
95 ms35948 KiB
#define taskname "test" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define fi first #define se second typedef long long lli; typedef pair<int, int> pii; const int maxn = 3005; const int inf = 1e9 + 9; int n, t; int u[maxn], v[maxn], d[maxn], e[maxn]; int dp[maxn][maxn]; void read_input() { cin >> n >> t; for(int i = 1; i <= n; ++i) cin >> u[i] >> v[i] >> d[i] >> e[i]; } void solve() { fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), inf); dp[1][0] = 0; for(int i = 1; i <= n; ++i) for(int j = 0; j <= n; ++j) { if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + d[i] + v[i] - 2 * t * i); dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + u[i] + v[i]); dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + d[i] + v[i] - 2 * t * i); if(j > 0) dp[i + 1][j - 1] = min(dp[i + 1][j - 1], dp[i][j] + u[i] + e[i] + 2 * t * i); if(j > 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + d[i] + e[i]); } cout << (n + 1) * t + dp[n + 1][0] << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); read_input(); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...