結果

問題 No.318 学学学学学
ユーザー azbrugbyazbrugby
提出日時 2019-03-02 20:30:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 1,525 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 18,156 KB
最終ジャッジ日時 2023-09-04 21:21:25
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
5,304 KB
testcase_01 AC 38 ms
6,700 KB
testcase_02 AC 46 ms
6,964 KB
testcase_03 AC 29 ms
6,000 KB
testcase_04 AC 39 ms
6,796 KB
testcase_05 AC 286 ms
17,872 KB
testcase_06 AC 202 ms
12,008 KB
testcase_07 AC 182 ms
9,844 KB
testcase_08 AC 155 ms
7,808 KB
testcase_09 AC 132 ms
6,308 KB
testcase_10 AC 97 ms
5,288 KB
testcase_11 AC 301 ms
18,156 KB
testcase_12 AC 184 ms
11,308 KB
testcase_13 AC 138 ms
9,164 KB
testcase_14 AC 108 ms
7,396 KB
testcase_15 AC 80 ms
6,176 KB
testcase_16 AC 58 ms
5,012 KB
testcase_17 AC 163 ms
12,016 KB
testcase_18 AC 137 ms
11,552 KB
testcase_19 AC 155 ms
12,108 KB
testcase_20 AC 42 ms
5,304 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define printf printf_s
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 100001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll n, a[N],lst_i[N];
map<ll, ll> mp1, mp2;
priority_queue<pos> q;

int main() {
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (mp1.find(a[i]) == mp1.end()) { mp1[a[i]] = i; mp2[a[i]] = i; }
		mp1[a[i]] = min(i, mp1[a[i]]);
		mp2[a[i]] = max(i, mp2[a[i]]);
	}
	memset(lst_i, -1, sizeof(lst_i));
	for (int i = 0; i < n; i++) {
		if (mp1[a[i]] == i)lst_i[i] = mp2[a[i]];
	}
	for (int i = 0; i < n; i++) {
		if (lst_i[i] != -1)q.push(mk(a[i], lst_i[i]));
		while (q.top().second < i)q.pop();
		if (i != 0)cout << ' ';
		cout << q.top().first;
	}
	cout << endl;
	return 0;
}
0