提出 #40847748


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int main(){
	int n,m;
	cin >> n >> m;
	vector<int>a(n);
	rep(i,0,n)cin >> a[i];

	vector<int>right(m+1);
	rep(i,0,n)right[a[i]]=i;

	vector<int>ans;
	vector<bool>used(m+1);
	rep(i,0,n){
		if(used[a[i]])continue;
		used[a[i]]=true;
		while(ans.size()>0 && ans.back()>a[i] && right[ans.back()]>i){
			used[ans.back()]=false;
			ans.pop_back();
		}
		ans.push_back(a[i]);
	}
	for(auto x:ans)cout << x << ' ';
}

提出情報

提出日時
問題 G - Minimum Permutation
ユーザ kyopro_friends
言語 C++ (GCC 9.2.1)
得点 600
コード長 521 Byte
結果 AC
実行時間 72 ms
メモリ 5836 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 47
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_max_03.txt, 01_max_04.txt, 01_max_05.txt, 01_max_06.txt, 01_max_07.txt, 01_max_08.txt, 01_max_09.txt, 01_max_10.txt, 01_max_11.txt, 01_max_12.txt, 01_max_13.txt, 01_max_14.txt, 01_max_15.txt, 01_max_16.txt, 01_max_17.txt, 01_max_18.txt, 01_max_19.txt, 01_max_20.txt, 01_max_21.txt, 01_max_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt, 02_random_30.txt, 02_random_31.txt, 02_random_32.txt, 02_random_33.txt, 02_random_34.txt, 02_random_35.txt, 02_random_36.txt, 02_random_37.txt, 02_random_38.txt, 03_handmade_39.txt, 03_handmade_40.txt, 03_handmade_41.txt, 03_handmade_42.txt, 03_handmade_43.txt, 03_handmade_44.txt, 03_handmade_45.txt, 03_handmade_46.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 11 ms 3440 KiB
00_sample_01.txt AC 2 ms 3320 KiB
00_sample_02.txt AC 2 ms 3368 KiB
01_max_03.txt AC 33 ms 3768 KiB
01_max_04.txt AC 32 ms 3912 KiB
01_max_05.txt AC 32 ms 3832 KiB
01_max_06.txt AC 32 ms 3836 KiB
01_max_07.txt AC 33 ms 3916 KiB
01_max_08.txt AC 39 ms 3916 KiB
01_max_09.txt AC 40 ms 3972 KiB
01_max_10.txt AC 39 ms 3832 KiB
01_max_11.txt AC 40 ms 3876 KiB
01_max_12.txt AC 42 ms 3832 KiB
01_max_13.txt AC 59 ms 4824 KiB
01_max_14.txt AC 57 ms 4876 KiB
01_max_15.txt AC 58 ms 4884 KiB
01_max_16.txt AC 58 ms 4900 KiB
01_max_17.txt AC 61 ms 4824 KiB
01_max_18.txt AC 69 ms 5728 KiB
01_max_19.txt AC 69 ms 5648 KiB
01_max_20.txt AC 67 ms 5836 KiB
01_max_21.txt AC 68 ms 5616 KiB
01_max_22.txt AC 70 ms 5692 KiB
02_random_23.txt AC 33 ms 3912 KiB
02_random_24.txt AC 31 ms 3820 KiB
02_random_25.txt AC 30 ms 3888 KiB
02_random_26.txt AC 36 ms 3972 KiB
02_random_27.txt AC 35 ms 3764 KiB
02_random_28.txt AC 42 ms 3832 KiB
02_random_29.txt AC 25 ms 3676 KiB
02_random_30.txt AC 49 ms 4752 KiB
02_random_31.txt AC 38 ms 3908 KiB
02_random_32.txt AC 44 ms 4028 KiB
02_random_33.txt AC 54 ms 4468 KiB
02_random_34.txt AC 4 ms 3504 KiB
02_random_35.txt AC 29 ms 3564 KiB
02_random_36.txt AC 2 ms 3480 KiB
02_random_37.txt AC 41 ms 4224 KiB
02_random_38.txt AC 32 ms 3612 KiB
03_handmade_39.txt AC 2 ms 3392 KiB
03_handmade_40.txt AC 41 ms 3796 KiB
03_handmade_41.txt AC 54 ms 4524 KiB
03_handmade_42.txt AC 58 ms 4900 KiB
03_handmade_43.txt AC 72 ms 5836 KiB
03_handmade_44.txt AC 5 ms 3444 KiB
03_handmade_45.txt AC 2 ms 3516 KiB
03_handmade_46.txt AC 33 ms 3916 KiB