結果

問題 No.258 回転寿司(2)
ユーザー LayCurse
提出日時 2015-07-31 22:29:29
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 4 ms
コード長 2,466 Byte
コンパイル時間 2,886 ms
使用メモリ 8,920 KB
最終ジャッジ日時 2019-08-25 16:19:08

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
90_match_case1.txt AC 2 ms
6,872 KB
90_match_case2.txt AC 3 ms
6,872 KB
gen_case1.txt AC 3 ms
8,916 KB
gen_case2.txt AC 3 ms
6,868 KB
gen_case3.txt AC 3 ms
6,872 KB
gen_case4.txt AC 3 ms
8,920 KB
gen_case5.txt AC 3 ms
6,872 KB
gen_case6.txt AC 3 ms
6,872 KB
gen_case7.txt AC 3 ms
6,868 KB
gen_case8.txt AC 3 ms
6,868 KB
gen_case9.txt AC 3 ms
6,868 KB
gen_case10.txt AC 3 ms
6,872 KB
gen_case11.txt AC 4 ms
6,872 KB
gen_case12.txt AC 3 ms
6,872 KB
gen_case13.txt AC 3 ms
6,872 KB
gen_case14.txt AC 3 ms
6,868 KB
gen_case15.txt AC 2 ms
6,868 KB
gen_case16.txt AC 3 ms
6,872 KB
gen_case17.txt AC 2 ms
6,872 KB
gen_case18.txt AC 3 ms
6,872 KB
gen_case19.txt AC 3 ms
6,872 KB
gen_case20.txt AC 3 ms
8,920 KB
sample1.txt AC 3 ms
6,872 KB
sample2.txt AC 3 ms
6,872 KB
sample3.txt AC 3 ms
6,868 KB
sample4.txt AC 3 ms
6,872 KB
system_test1.txt AC 3 ms
6,868 KB
system_test2.txt AC 3 ms
6,868 KB
system_test3.txt AC 3 ms
8,912 KB
system_test4.txt AC 3 ms
6,872 KB
system_test5.txt AC 3 ms
6,868 KB
system_test6.txt AC 3 ms
6,868 KB
system_test7.txt AC 3 ms
6,868 KB
system_test8.txt AC 3 ms
6,868 KB
system_test9.txt AC 3 ms
6,868 KB
system_test10.txt AC 3 ms
6,868 KB
system_test11.txt AC 2 ms
6,868 KB
system_test12.txt AC 3 ms
6,872 KB
system_test13.txt AC 3 ms
6,872 KB
system_test14.txt AC 2 ms
6,872 KB
system_test15.txt AC 3 ms
6,868 KB
system_test16.txt AC 3 ms
6,868 KB
system_test17.txt AC 3 ms
6,872 KB
system_test18.txt AC 3 ms
6,868 KB
system_test19.txt AC 3 ms
6,872 KB
system_test20.txt AC 3 ms
6,868 KB
system_test21.txt AC 3 ms
6,872 KB
system_test22.txt AC 3 ms
6,868 KB
system_test23.txt AC 3 ms
6,872 KB
system_test24.txt AC 2 ms
8,920 KB
system_test25.txt AC 3 ms
6,868 KB
system_test26.txt AC 3 ms
6,872 KB
system_test27.txt AC 3 ms
6,868 KB
system_test28.txt AC 3 ms
6,868 KB
system_test29.txt AC 2 ms
6,872 KB
system_test30.txt AC 3 ms
6,872 KB
system_test31.txt AC 3 ms
8,916 KB
system_test32.txt AC 4 ms
6,872 KB
system_test33.txt AC 3 ms
6,872 KB
system_test34.txt AC 3 ms
6,872 KB
system_test35.txt AC 3 ms
6,868 KB
system_test36.txt AC 4 ms
6,868 KB
system_test37.txt AC 3 ms
6,872 KB
system_test38.txt AC 3 ms
6,872 KB
system_test39.txt AC 3 ms
6,872 KB
system_test40.txt AC 3 ms
6,872 KB
system_test41.txt AC 3 ms
6,872 KB
system_test42.txt AC 3 ms
6,872 KB
system_test43.txt AC 3 ms
6,872 KB
system_test44.txt AC 3 ms
6,868 KB
system_test45.txt AC 3 ms
6,872 KB
テストケース一括ダウンロード

ソースコード

diff #
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N, V[10000];

int dp[10000];
int res[10000], ress;

int main(){
  int i, j, k;

  reader(&N);
  rep(i,N) reader(V+i);

  for(i=N-1;i>=0;i--){
    dp[i] = max(dp[i+1], dp[i+2]+V[i]);
  }

  i = 0;
  while(i<N){
    if(dp[i] == dp[i+1]){ i++; continue; }
    res[ress++] = i+1;
    i += 2;
  }

  writerLn(dp[0]);
  writerArr(res,ress);

  return 0;
}
0