結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー | albatross_35 |
提出日時 | 2020-06-12 22:08:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 2,057 bytes |
コンパイル時間 | 1,653 ms |
コンパイル使用メモリ | 168,400 KB |
実行使用メモリ | 81,672 KB |
最終ジャッジ日時 | 2023-09-06 10:30:53 |
合計ジャッジ時間 | 2,742 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 27 ms
58,740 KB |
testcase_03 | AC | 34 ms
73,004 KB |
testcase_04 | AC | 13 ms
25,948 KB |
testcase_05 | AC | 10 ms
19,928 KB |
testcase_06 | AC | 15 ms
32,092 KB |
testcase_07 | AC | 17 ms
36,184 KB |
testcase_08 | AC | 14 ms
27,972 KB |
testcase_09 | AC | 12 ms
23,844 KB |
testcase_10 | AC | 36 ms
73,020 KB |
testcase_11 | AC | 24 ms
48,620 KB |
testcase_12 | AC | 20 ms
42,544 KB |
testcase_13 | AC | 10 ms
19,788 KB |
testcase_14 | AC | 37 ms
73,004 KB |
testcase_15 | AC | 19 ms
40,240 KB |
testcase_16 | AC | 14 ms
28,064 KB |
testcase_17 | AC | 22 ms
44,344 KB |
testcase_18 | AC | 36 ms
75,064 KB |
testcase_19 | AC | 10 ms
17,712 KB |
testcase_20 | AC | 1 ms
4,380 KB |
testcase_21 | AC | 40 ms
81,672 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; /////////////////////////////////////////// const long long int INF = 1LL<<60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll>; using matrix = vector<vector<ll>>; #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define rp(i,N) for(ll i = 0; i < (ll)N; i++) #define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i) template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; } template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; } template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根; #define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート #define p_queue(v) priority_queue<v, vector<v>, greater<v> > template<class T> inline void princ(T x){cout<<x<<" ";}; template<class T> inline void print(T x){cout<<x<<"\n";}; template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } /////////////////////////////////////////////////////////////////////////////////// ll dp[1005][10010]; void solve(){ int n; cin >> n; Vi y(n); rp(i,n) cin >> y.at(i); rp(i,n){ if(i==0){ rp(j,y[i]) dp[0][j]=y[i]-j; repi(j,y[i],10001) dp[0][j]=0; continue; } rp(j,10001){ if(j==0) { dp[i][j]=dp[i-1][j]+y[i]; continue; } dp[i][j]=min(dp[i][j-1],dp[i-1][j]+abs(y[i]-j)); } } print(dp[n-1][10000]); return; } int main(){ cin.tie(0);ios::sync_with_stdio(false); std::cout<<std::fixed<<std::setprecision(30); solve(); return 0; }