結果
| 問題 |
No.318 学学学学学
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-21 19:45:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 651 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 51,524 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-06-22 16:18:32 |
| 合計ジャッジ時間 | 3,494 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | int a;scanf("%d",&a);
| ~~~~~^~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",b+i);
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<set>
using namespace std;
int b[110000];
int z[110000];
int l[110000];
int r[110000];
int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
scanf("%d",b+i);
z[i]=b[i];
l[i]=r[i]=-1;
}
std::sort(z,z+a);
for(int i=0;i<a;i++){
int t=lower_bound(z,z+a,b[i])-z;
if(l[t]==-1)l[t]=i;
}
for(int i=a-1;i>=0;i--){
int t=lower_bound(z,z+a,b[i])-z;
if(r[t]==-1)r[t]=i;
}
set<int>S;
for(int i=0;i<a;i++){
if(i)printf(" ");
int t=lower_bound(z,z+a,b[i])-z;
if(i==l[t]){
S.insert(z[t]);
}
printf("%d",*(S.rbegin()));
if(i==r[t])S.erase(z[t]);
}
printf("\n");
}
piyoko_212