結果

問題 No.318 学学学学学
ユーザー かにかに
提出日時 2015-12-11 01:54:10
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,104 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 153,200 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 10:47:34
合計ジャッジ時間 6,169 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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[10000];
	int ans[10000];
	set<int> s;
	rep(i, n){
		cin >> A[i];
		s.insert(A[i]);
	}
	for (auto it = s.begin(); it != s.end(); it++){
		int f = -1, e = -1;
		rep(i, n){
			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{
			ans[f] = *it;
		}
	}
	rep(i, n){
		cout << ans[i];
		if (i != n - 1){
			cout << " ";
		}
	}
	cout << endl;
}

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