結果

問題 No.318 学学学学学
ユーザー かにかに
提出日時 2015-12-11 02:14:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,252 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 151,944 KB
実行使用メモリ 13,236 KB
最終ジャッジ日時 2023-10-13 10:48:03
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
8,700 KB
testcase_01 AC 342 ms
4,492 KB
testcase_02 AC 503 ms
4,588 KB
testcase_03 AC 233 ms
4,348 KB
testcase_04 AC 392 ms
4,436 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout<<(p)<<endl;
#define pi 3.1415926535
using namespace std;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ll gcd(ll a, ll b){
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

void solve() {
	int n;
	cin >> n;
	int A[100000];
	int ans[100000];
	set<int> s;
	rep(i, n){
		cin >> A[i];
		ans[i] = A[i];
		s.insert(A[i]);
	}
	for (auto it = s.begin(); it != s.end(); it++){
		int f = -1, e = -1;
		rep(i, n){
			if (f != -1 && e != -1){
				for (int j = f; j <= e; j++){
					ans[j] = *it;
				}
				f = -1;
				e = -1;
			}
			if (A[i] == *it && f == -1){
				f = i;
			}
			else if (A[i] == *it && f != -1){
				e = i;
			}
		}
		if (f != -1 && e != -1){
			for (int i = f; i <= e; i++){
				ans[i] = *it;
			}
		}
		else if (f != -1){
			ans[f] = *it;
		}
	}
	rep(i, n){
		cout << ans[i];
		if (i != n - 1){
			cout << " ";
		}
	}
	cout << endl;
}

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