結果

問題 No.258 回転寿司(2)
ユーザー wahr69wahr69
提出日時 2015-08-01 00:09:10
言語 C++11
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 782 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 65,140 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 09:36:10
合計ジャッジ時間 3,924 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other WA * 67
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;

	vector<int> V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}

	vector<bool> toru(N);
	fill(toru.begin(), toru.end(), false);

	for (int count = 0; count < 100; ++count) {
		for (int i = 0; i < N; ++i) {
			if (i == 0 ||
				(V[i] > V[i - 1]) ||
				(i - 1 != 0 && toru[i - 2])) {

				if (i == N - 1 ||
					(V[i] > V[i + 1]) ||
					(i + 1 != N - 1 && toru[i + 2])) {

					toru[i] = true;
				}
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < N; ++i) {
		if (toru[i]) {
			sum += V[i];
		}
	}

	cout << sum << endl;
	for (int i = 0; i < N; ++i) {
		if (toru[i]) {
			cout << (i + 1) << " ";
		}
	}
	cout << endl;

	getchar();
	getchar();
}
0