結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2022-09-02 23:06:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,227 bytes |
コンパイル時間 | 3,834 ms |
コンパイル使用メモリ | 263,132 KB |
実行使用メモリ | 816,512 KB |
最終ジャッジ日時 | 2024-11-16 05:50:32 |
合計ジャッジ時間 | 29,873 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 MLE * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ch = char; using ll = long long; using ld = long double; using db = double; using st = string; using vdb = vector<db>; using vvdb = vector<vdb>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vd = vector<ld>; using vvd = vector<vd>; using vs = vector<st>; using vvs = vector<vs>; using vc = vector<ch>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; const ll mod = 998244353; const ll MOD = 1000000007; using vp = vector<pair<ll,ll>>; #define fi first #define se second int main(){ ll H,W; cin>>H>>W; vvc X(H,vc(W)); for(int i=0; i<H; i++){ for(int j=0; j<W; j++) cin>>X[i][j]; } vvs A(H,vs(W)); A[0][0]=X[0][0]; for(int i=1; i<H; i++){ A.at(i).at(0)=A.at(i-1).at(0)+X.at(i).at(0); } for(int i=1; i<W; i++){ A.at(0).at(i)=A.at(0).at(i-1)+X.at(0).at(i); } for(int i=1; i<H; i++){ for(int j=1; j<W; j++){ st b=min(A.at(i-1).at(j),A.at(i).at(j-1)); A.at(i).at(j)=b+X.at(i).at(j); } if(i>1){ X.at(i-2).erase(X.at(i-2).begin(), X.at(i-2).end()); X.at(i-2).shrink_to_fit(); } } cout<<A.at(H-1).at(W-1)<<endl; }