結果
| 問題 | No.318 学学学学学 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-06 14:10:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 599 bytes |
| 記録 | |
| コンパイル時間 | 1,646 ms |
| コンパイル使用メモリ | 167,764 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 02:47:08 |
| 合計ジャッジ時間 | 4,845 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
int n;cin >> n;
vector<int> a(n),m(n);
for(int i=0;i<n;i++){
cin >> a[i];
}
m[n-1]=a[n-1];
for(int i=n-2;i>=0;i--){
m[i]=max(m[i+1],a[i]);
}
for(int i=1;i<n-1;i++){
if(m[i+1]>a[i]){
chmax(a[i],a[i-1]);
}
}
for(int i=0;i<n;i++){
cout << a[i] << " ";
}
cout << endl;
}