# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
481257 | FatihSolak | Skyline (IZhO11_skyline) | C++17 | 229 ms | 1180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define N 305
using namespace std;
int h[N];
void solve(){
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> h[i];
}
vector<vector<int>> dp(N,vector<int>(N,1e9));
dp[0][0] = 0;
for(int x=1;x<=n;x++){
vector<vector<int>> ndp(N,vector<int>(N,1e9));
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
ndp[max(0,j- i)][max(0,h[x] - i)] = min(ndp[max(0,j- i)][max(0,h[x] - i)],dp[i][j] + 7*i);
}
}
for(int i=N-1;i>=0;i--){
for(int j=N-1;j>=0;j--){
ndp[i][max(0,j-1)] = min(ndp[i][max(0,j-1)],ndp[i][j] + 3);
ndp[max(0,i-1)][max(0,j-1)] = min(ndp[max(0,i-1)][max(0,j-1)],ndp[i][j] + 5);
}
}
dp = ndp;
}
cout << dp[0][0];
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |