結果
問題 |
No.258 回転寿司(2)
|
ユーザー |
![]() |
提出日時 | 2015-08-01 00:54:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,034 bytes |
コンパイル時間 | 1,252 ms |
コンパイル使用メモリ | 158,776 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 09:50:40 |
合計ジャッジ時間 | 4,052 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 67 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<to;x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N; int V[1010]; int ma[2020]; int from[2020]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>V[i]; for(i=N-1;i>=0;i--) { for(x=i+2;x<N+2;x++) if(ma[i]<ma[x]+V[i]) { ma[i]=ma[x]+V[i]; from[i]=x; } } int id=0; FOR(i,N) if(ma[i]>ma[id]) id=i; while(1) { _P("%d",id+1); id=from[id]; if(id>=N) { _P("\n"); break; } _P(" "); } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }