結果

問題 No.318 学学学学学
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-12-11 20:07:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,047 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 2,844 ms
コンパイル使用メモリ 81,212 KB
実行使用メモリ 14,136 KB
最終ジャッジ日時 2023-09-04 17:37:38
合計ジャッジ時間 8,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,408 KB
testcase_01 AC 15 ms
5,280 KB
testcase_02 AC 18 ms
5,588 KB
testcase_03 AC 12 ms
4,848 KB
testcase_04 AC 15 ms
5,164 KB
testcase_05 AC 121 ms
14,136 KB
testcase_06 AC 740 ms
8,700 KB
testcase_07 AC 724 ms
7,044 KB
testcase_08 AC 577 ms
5,772 KB
testcase_09 AC 365 ms
4,788 KB
testcase_10 AC 70 ms
4,384 KB
testcase_11 AC 130 ms
14,132 KB
testcase_12 AC 65 ms
8,752 KB
testcase_13 AC 49 ms
7,036 KB
testcase_14 AC 39 ms
5,648 KB
testcase_15 AC 33 ms
4,968 KB
testcase_16 AC 27 ms
4,384 KB
testcase_17 AC 1,047 ms
8,780 KB
testcase_18 AC 45 ms
8,824 KB
testcase_19 AC 1,041 ms
8,824 KB
testcase_20 AC 26 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0