結果
問題 | No.318 学学学学学 |
ユーザー |
|
提出日時 | 2016-09-29 02:11:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 102 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 1,917 ms |
コンパイル使用メモリ | 180,008 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-06-22 18:03:51 |
合計ジャッジ時間 | 4,651 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)#define all(x) (x).begin(),(x).end()#define pb push_back#define fi first#define se secondint main(){int n;scanf(" %d", &n);vector<int> a(n);rep(i,n) scanf(" %d", &a[i]);map<int,int> most_right;for(int i=n-1; i>=0; --i){if(most_right.find(a[i]) == most_right.end()) most_right[a[i]]=i;}set<int> s;rep(i,n){s.insert(a[i]);if(i) printf(" ");printf("%d", *s.rbegin());if(i == most_right[a[i]]) s.erase(a[i]);}printf("\n");return 0;}