結果
問題 |
No.318 学学学学学
|
ユーザー |
|
提出日時 | 2015-12-11 20:07:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 934 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 1,051 ms |
コンパイル使用メモリ | 79,704 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-06-22 15:36:51 |
合計ジャッジ時間 | 7,043 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:14:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | int p; scanf("%d", &p); | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream> #include <algorithm> #include <unordered_map> #include <map> using namespace std; int n; int b[100005]; unordered_map<int, pair<int, int>> dic; int main(void) { int n; scanf("%d", &n); for(int i=0; i<n; i++) { int p; scanf("%d", &p); int x, y; if(dic.find(p) == dic.end()) { x = n, y = -1; } else { pair<int, int> pr = dic[p]; x = pr.first, y = pr.second; } x = min(x, i); y = max(y, i); dic[p] = make_pair(x, y); } map<int, pair<int, int>> ordered_dic(dic.begin(), dic.end()); for(pair<int, pair<int, int>> kv : ordered_dic) { for(int i=kv.second.first; i<=kv.second.second; i++) { b[i] = kv.first; } } printf("%d", b[0]); for(int i=1; i<n; i++) { putchar(' '); printf("%d", b[i]); } putchar('\n'); return 0; }