結果
問題 |
No.318 学学学学学
|
ユーザー |
![]() |
提出日時 | 2016-05-26 12:18:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,115 bytes |
コンパイル時間 | 759 ms |
コンパイル使用メモリ | 72,276 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-07 15:42:36 |
合計ジャッジ時間 | 4,430 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d",a+i); | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; int a[100100], nxt[100100]; bool used[100100]; int main(void) { int i, n; map<int,pair<int,int>> mp; scanf("%d",&n); rep (i,n) { scanf("%d",a+i); if (!mp.count(a[i])) mp[a[i]].first = i; else mp[a[i]].second = i; nxt[i] = i+1; } for (auto p = mp.rbegin(); p != mp.rend(); p++) { int s, e; s = p->second.first; e = p->second.second; while ((s = nxt[s]) <= e) { if (!used[s]) a[s] = p->first; } e = s; s = p->second.first; used[s] = true; while (s < e) { int tmp = nxt[s]; nxt[s] = e; s = tmp; } } rep (i,n) printf("%d%c",a[i],i < n-1 ? ' ' : '\n'); return 0; }