結果
問題 |
No.318 学学学学学
|
ユーザー |
|
提出日時 | 2015-12-11 11:36:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 879 ms |
コンパイル使用メモリ | 56,944 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-06-22 15:27:37 |
合計ジャッジ時間 | 3,719 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | int N,x,i=0;scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&x); | ~~~~~^~~~~~~~~
ソースコード
#include <vector> #include <map> #include <cstdio> using namespace std; int main(){ int N,x,i=0;scanf("%d",&N); map<int,pair<int,int>>m; vector<int>v(N),sa(N),sb(N); map<int,int>s; for(;i<N;i++){ scanf("%d",&x); v[i]=x; if(m.find(x)==m.end())sa[i]++,m[x]={i,i},sb[i]++; else sb[m[x].second]--,m[x].second=i,sb[i]++; } for(i=0;i<N;i++){ if(sa[i])s[v[i]]=1; printf(i<N-1?"%d ":"%d\n",s.rbegin()->first); if(sb[i])s.erase(v[i]); } }