結果
問題 | No.318 学学学学学 |
ユーザー |
|
提出日時 | 2015-12-11 00:06:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 870 ms |
コンパイル使用メモリ | 77,248 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-06-22 14:18:12 |
合計ジャッジ時間 | 3,934 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <iostream>#include <vector>#include <map>#include <set>using namespace std;int main(){int n;cin >> n;vector<int> a(n);for(int i=0;i<n;i++)cin >> a[i];map<int, int> R;for(int i=n-1;i>=0;i--){if(!R.count(a[i])){R[a[i]] = i;}}set<int, greater<int>> stk;for(int i=0;i<n;i++){if(!stk.count(a[i])){stk.insert(a[i]);}while(!stk.empty() && R[*stk.begin()] <= i){stk.erase(stk.begin());}if(!stk.empty() && *stk.begin() > a[i]){a[i] = *stk.begin();}}for(int x : a){cout << x << " ";}return 0;}