結果

問題 No.318 学学学学学
ユーザー climpetclimpet
提出日時 2015-12-11 00:09:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 77,088 KB
実行使用メモリ 8,992 KB
最終ジャッジ日時 2023-09-04 16:11:46
合計ジャッジ時間 4,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,376 KB
testcase_01 AC 13 ms
4,416 KB
testcase_02 AC 16 ms
4,592 KB
testcase_03 AC 11 ms
4,376 KB
testcase_04 AC 15 ms
4,496 KB
testcase_05 AC 80 ms
8,912 KB
testcase_06 AC 61 ms
8,980 KB
testcase_07 AC 62 ms
8,908 KB
testcase_08 AC 62 ms
8,808 KB
testcase_09 AC 62 ms
8,856 KB
testcase_10 AC 62 ms
8,912 KB
testcase_11 AC 80 ms
8,800 KB
testcase_12 AC 77 ms
8,928 KB
testcase_13 AC 73 ms
8,980 KB
testcase_14 AC 69 ms
8,976 KB
testcase_15 AC 66 ms
8,920 KB
testcase_16 AC 58 ms
8,800 KB
testcase_17 AC 61 ms
8,904 KB
testcase_18 AC 54 ms
8,860 KB
testcase_19 AC 57 ms
8,912 KB
testcase_20 AC 56 ms
8,992 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;

int main(){
	const int INF = 1010101010;

	int n;
	scanf("%d", &n);
	vector<pii> v(n + 1);
	for(int i = 0; i < n; ++i){
		int x;
		scanf("%d", &x);
		v[i] = pii(-x, i);
	}
	v[n] = pii(INF, INF);
	sort(v.begin(), v.end());

	vector<int> b(n);
	set<int> st;
	for(int i = 0; i < n; ++i){
		st.insert(i);
	}
	st.insert(INF);

	for(int i = 0; i < n; ){
		int j;
		int val = -v[i].first;
		for(j = i + 1; v[j].first == -val; ++j);
		int l = v[i].second, r = v[j - 1].second;
		for(auto it = st.lower_bound(l); *it <= r; ){
			b[*it] = val;
			it = st.erase(it);
		}
		i = j;
	}

	for(int i = 0; i < n; ++i){
		printf("%d%c", b[i], i + 1 == n ? '\n' : ' ');
	}
}
0