結果
問題 |
No.318 学学学学学
|
ユーザー |
![]() |
提出日時 | 2015-12-21 19:40:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 674 bytes |
コンパイル時間 | 639 ms |
コンパイル使用メモリ | 45,640 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 18:05:17 |
合計ジャッジ時間 | 4,038 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int a;scanf("%d",&a); | ~~~~~^~~~~~~~~ main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d",b+i); | ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h> #include<algorithm> #include<stack> 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; } stack<int>S; for(int i=0;i<a;i++){ if(i)printf(" "); int t=lower_bound(z,z+a,b[i])-z; if(S.size()==0||z[S.top()]<b[i]){ S.push(t); } printf("%d",z[S.top()]); while(S.size()&&r[S.top()]<=i){ S.pop(); } } printf("\n"); }