結果

問題 No.318 学学学学学
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-12-11 20:15:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,044 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 1,986 ms
コンパイル使用メモリ 81,516 KB
実行使用メモリ 14,124 KB
最終ジャッジ日時 2023-09-04 17:38:22
合計ジャッジ時間 7,903 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,580 KB
testcase_01 AC 14 ms
5,280 KB
testcase_02 AC 17 ms
5,636 KB
testcase_03 AC 11 ms
5,116 KB
testcase_04 AC 14 ms
5,372 KB
testcase_05 AC 94 ms
13,988 KB
testcase_06 AC 733 ms
8,924 KB
testcase_07 AC 719 ms
7,068 KB
testcase_08 AC 577 ms
5,824 KB
testcase_09 AC 362 ms
5,100 KB
testcase_10 AC 69 ms
4,380 KB
testcase_11 AC 101 ms
14,124 KB
testcase_12 AC 57 ms
8,968 KB
testcase_13 AC 46 ms
7,056 KB
testcase_14 AC 37 ms
6,032 KB
testcase_15 AC 32 ms
4,944 KB
testcase_16 AC 28 ms
4,380 KB
testcase_17 AC 1,042 ms
8,828 KB
testcase_18 AC 43 ms
9,160 KB
testcase_19 AC 1,044 ms
8,836 KB
testcase_20 AC 26 ms
4,384 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// (ΦωΦ)<悪あがき
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
using namespace std;

int n, p, x, y, i;
int b[100005];
unordered_map<int, pair<int, int>> dic;

int main(void) {
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%d", &p);
    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(i=kv.second.first; i<=kv.second.second; i++) {
      b[i] = kv.first;
    }
  }
  printf("%d", b[0]);
  for(i=1; i<n; i++) {
    printf(" %d", b[i]);
  }
  putchar('\n');
  return 0;
}
0