結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
9,128 KB
testcase_01 AC 28 ms
6,184 KB
testcase_02 AC 35 ms
6,756 KB
testcase_03 AC 22 ms
5,680 KB
testcase_04 AC 30 ms
6,340 KB
testcase_05 AC 247 ms
19,744 KB
testcase_06 TLE -
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];
	map<int, vector<int> > m;
	set<int> s;
	rep(i, n){
		cin >> A[i];
		ans[i] = A[i];
		m[A[i]].push_back(i);
		s.insert(A[i]);
	}
	for (auto it = s.begin(); it != s.end(); it++){
		if (m[*it].size() == 1){
			ans[m[*it][0]] = *it;
		}
		else if (m[*it].size() == 2){
			for (int i = m[*it][0]; i <= m[*it][1]; i++){
				ans[i] = *it;
			}
		}
	}
	rep(i, n){
		cout << ans[i];
		if (i != n - 1){
			cout << " ";
		}
	}
	cout << endl;
}

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