結果

問題 No.318 学学学学学
ユーザー ciel
提出日時 2015-12-11 18:22:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 52,288 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-06-22 15:32:25
合計ジャッジ時間 2,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         int N,x,i=0;scanf("%d",&N);
      |                     ~~~~~^~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d",&x);
      |                 ~~~~~^~~~~~~~~

ソースコード

diff #

#include <vector>
#include <map>
#include <cstdio>
int main(){
	int N,x,i=0;scanf("%d",&N);
	std::map<int,int>m,s;
	std::vector<int>v(N),sa(N),sb(N);
	for(;i<N;sb[i]++,m[x]=i++){
		scanf("%d",&x);
		v[i]=x;
		if(m.find(x)==m.end())sa[i]++;else sb[m[x]]--;
	}
	for(i=-1;++i<N;){
		if(sa[i])s[v[i]]=1;
		printf(i<N-1?"%d ":"%d\n",s.rbegin()->first);
		if(sb[i])s.erase(v[i]);
	}
}
0