結果

問題 No.318 学学学学学
ユーザー satanicsatanic
提出日時 2015-12-11 00:37:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 790 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 67,640 KB
実行使用メモリ 13,048 KB
最終ジャッジ日時 2023-10-13 10:43:48
合計ジャッジ時間 5,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
13,048 KB
testcase_01 AC 162 ms
4,352 KB
testcase_02 AC 231 ms
4,520 KB
testcase_03 AC 107 ms
4,348 KB
testcase_04 AC 180 ms
4,352 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, input, start, end, num_kind;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n,0);
  set<int> num;
  
  for(int i=0; i<n; ++i){
    cin >> input;
    a[i] = input;
    num.insert(input);
  }
  num_kind=num.size();
  for(set<int>::iterator it=num.begin(); it!=num.end(); ++it){
    start=-1; end=-1;
    for(int j=0; j<n; ++j){
      if(a[j]==*it){
	start=j;
	break;
      }
    }
    if(start==-1) continue;
    for(int j=n-1; j>=0; --j){
      if(a[j]==*it){
	end=j;
	break;
      }
    }
    if(end==-1) continue;
    for(;start<=end; ++start) b[start]=*it;
  }
  for(int i=0; i<n; ++i){
    cout << b[i] << ' ';
  }
  cout << "\n";

  return 0;
}
0