結果

問題 No.258 回転寿司(2)
ユーザー YoshiRyuYoshiRyu
提出日時 2017-03-07 19:24:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,293 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 162,560 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 11:26:27
合計ジャッジ時間 3,956 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 1 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 1 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 1 ms
5,376 KB
testcase_60 AC 1 ms
5,376 KB
testcase_61 AC 1 ms
5,376 KB
testcase_62 AC 1 ms
5,376 KB
testcase_63 AC 1 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
testcase_65 AC 1 ms
5,376 KB
testcase_66 AC 1 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void Slove()’:
main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 | #define SF(f,v) scanf(f,v)
      |                 ~~~~~^~~~~
main.cpp:8:17: note: in expansion of macro ‘SF’
    8 | #define SF_N(v) SF("%d",&v)
      |                 ^~
main.cpp:25:9: note: in expansion of macro ‘SF_N’
   25 |         SF_N(N);        // 寿司の数
      |         ^~~~
main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 | #define SF(f,v) scanf(f,v)
      |                 ~~~~~^~~~~
main.cpp:8:17: note: in expansion of macro ‘SF’
    8 | #define SF_N(v) SF("%d",&v)
      |                 ^~
main.cpp:26:16: note: in expansion of macro ‘SF_N’
   26 |         rep(N) SF_N(V[i]);      // 美味しさ
      |                ^~~~

ソースコード

diff #

#include "bits/stdc++.h"

// マクロ群
#define REP(i,n) for(int i=0;i<n;++i)
#define REP2(i,a,b) for (int i=(a);i<(b);++i)
#define rep(n) REP(i,n)
#define SF(f,v) scanf(f,v)
#define SF_N(v) SF("%d",&v)
#define SF_S(v) SF("%s",v)
#define PF(f,v) printf(f,v)
#define PFS_N(v) PF("%d ",v)
#define PFS_S(v) PF("%s ",v)
#define PFL_N(v) PF("%d\n",v)
#define PFL_S(v) PF("%s\n",v)


using namespace std;

const int ARRMAX = 1024;

void Slove()
{
	int N, V[ARRMAX];

	SF_N(N);	// 寿司の数
	rep(N) SF_N(V[i]);	// 美味しさ
	V[N] = -1;	// ループ処理調整用

	vector<int> eated;

	int befor = 0;
	int after = 0;
	int bast = 0;
	int dontEatPosi = -1;
	REP2(i, 0, N + 1)
	{
		after = befor + V[i];
		befor = bast;

		// 最大値と変化がない = 食べない
		if (bast > after)
		{
			// 1つ前の位置から開始して、前回食べれなかった位置に達するまで一個飛ばしで遡る
			for (int j = i - 1; j > dontEatPosi; j -= 2)
			{
				eated.push_back(j + 1);	// 位置を記憶する
			}

			dontEatPosi = i;

			after = bast;
		}
		else
		{
			bast = after;
		}
	}

	// 回答1
	PFL_N(bast);

	// 回答2
	sort(eated.begin(), eated.end());	// 並べ替え
	for (auto item : eated) PFS_N(item);
	PFL_S("\n");
}

int main()
{
	Slove();
	return 0;
}
0