結果

問題 No.258 回転寿司(2)
ユーザー mint6421mint6421
提出日時 2019-07-02 21:20:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 163,360 KB
実行使用メモリ 104,832 KB
最終ジャッジ日時 2024-04-26 10:20:28
合計ジャッジ時間 9,976 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
104,064 KB
testcase_01 AC 153 ms
104,832 KB
testcase_02 AC 92 ms
67,072 KB
testcase_03 AC 7 ms
7,808 KB
testcase_04 AC 59 ms
46,720 KB
testcase_05 AC 80 ms
50,944 KB
testcase_06 AC 134 ms
91,648 KB
testcase_07 AC 38 ms
31,104 KB
testcase_08 AC 63 ms
49,408 KB
testcase_09 AC 53 ms
33,792 KB
testcase_10 AC 16 ms
14,464 KB
testcase_11 AC 45 ms
38,144 KB
testcase_12 AC 71 ms
45,312 KB
testcase_13 AC 35 ms
29,312 KB
testcase_14 AC 123 ms
86,144 KB
testcase_15 AC 39 ms
33,408 KB
testcase_16 AC 38 ms
31,616 KB
testcase_17 AC 38 ms
31,872 KB
testcase_18 AC 138 ms
95,488 KB
testcase_19 AC 8 ms
7,680 KB
testcase_20 AC 101 ms
72,320 KB
testcase_21 AC 127 ms
88,576 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 90 ms
66,432 KB
testcase_27 AC 41 ms
33,920 KB
testcase_28 AC 151 ms
103,552 KB
testcase_29 AC 49 ms
41,088 KB
testcase_30 AC 23 ms
16,000 KB
testcase_31 AC 21 ms
14,976 KB
testcase_32 AC 53 ms
34,432 KB
testcase_33 AC 112 ms
79,104 KB
testcase_34 AC 80 ms
59,776 KB
testcase_35 AC 72 ms
54,400 KB
testcase_36 AC 26 ms
18,176 KB
testcase_37 AC 22 ms
15,360 KB
testcase_38 AC 59 ms
38,528 KB
testcase_39 AC 43 ms
36,736 KB
testcase_40 AC 92 ms
66,560 KB
testcase_41 AC 113 ms
80,256 KB
testcase_42 AC 39 ms
33,280 KB
testcase_43 AC 28 ms
23,680 KB
testcase_44 AC 123 ms
86,528 KB
testcase_45 AC 97 ms
70,912 KB
testcase_46 AC 6 ms
6,400 KB
testcase_47 AC 106 ms
71,936 KB
testcase_48 AC 25 ms
21,504 KB
testcase_49 AC 39 ms
33,408 KB
testcase_50 AC 7 ms
6,656 KB
testcase_51 AC 82 ms
61,952 KB
testcase_52 AC 73 ms
55,808 KB
testcase_53 AC 24 ms
16,640 KB
testcase_54 AC 110 ms
70,016 KB
testcase_55 AC 153 ms
104,064 KB
testcase_56 AC 98 ms
71,168 KB
testcase_57 AC 25 ms
21,120 KB
testcase_58 AC 70 ms
54,272 KB
testcase_59 AC 169 ms
96,000 KB
testcase_60 AC 18 ms
11,904 KB
testcase_61 AC 110 ms
77,696 KB
testcase_62 AC 42 ms
35,072 KB
testcase_63 AC 90 ms
65,664 KB
testcase_64 AC 151 ms
103,680 KB
testcase_65 AC 94 ms
68,864 KB
testcase_66 AC 8 ms
6,784 KB
testcase_67 AC 118 ms
83,968 KB
testcase_68 AC 123 ms
85,632 KB
testcase_69 AC 107 ms
75,520 KB
testcase_70 AC 37 ms
31,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:32:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   32 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

bool dp[1100][110000];

main(){
  int n;
  cin>>n;
  vector<int> v(n+1);
  rep(i,n){
    cin>>v[i+1];
  }

 
  dp[0][0]=true;
  dp[1][v[1]]=true;

  FOR(i,2,n+1){
    rep(j,100010){
      dp[i][j]|=dp[i-1][j];
      dp[i][j+v[i]]|=dp[i-2][j];
      if(dp[i][j]){
        //cout<<i<<' '<<j<<endl;
      }
    }
  }

  int res=0;
  rep(j,100010){
    if(dp[n][j]) res=j;
  }

  cout<<res<<endl;

  vector<int> ans;
  RFOR(i,n,1){
   if(dp[i][res]&&!dp[i-1][res]){
    ans.PB(i);
    res-=v[i];
   }
  }

  reverse(all(ans));
  rep(i,ans.size()){
    cout<<ans[i]<<' ';
  }
  cout<<endl;



}
0