Submission #34032


Source Code Expand

Copy
#include<iostream>
using namespace std;
int a[50],b[51],n;
int fi(int p){
	int i;
	if(p==n){
		for(i=0;b[i]<=100000;++i);
		return i;
	}
	int mn,mi=-1,mm;
	for(i=0;b[i]<=100000;++i){
		if(mi<0&&a[p]<=b[i]){
			mi=i;
			mn=b[i]-a[p];
		}else if(a[p]<=b[i]&&mn>b[i]-a[p]){
			mi=i;
			mn=b[i]-a[p];
		}
	}
	if(mi<0){
		b[i]=a[p];
		mm=fi(p+1);
		b[i]=100001;
	}else{
		b[i]=a[p];
		mm=fi(p+1);
		b[i]=100001;
		int s=b[mi];
		b[mi]=a[p];
		mm=min(mm,fi(p+1));
		b[mi]=s;
	}
	return mm;
}
int main(){
	int i;
	cin>>n;
	for(i=0;i<50;++i)
		cin>>a[i];
	fill(b,b+51,100001);
	cout<<fi(0)<<endl;
	return 0;
}

Submission Info

Submission Time
Task C - 積み重ね
User hakomo
Language C++ (G++ 4.6.4)
Score 0
Code Size 645 Byte
Status TLE
Exec Time 2038 ms
Memory 908 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 16
TLE × 26
RE × 2
Set Name Test Cases
All 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 02_maxrnd_00.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 02_maxrnd_05.txt, 02_maxrnd_06.txt, 02_maxrnd_07.txt, 02_maxrnd_08.txt, 02_maxrnd_09.txt, 02_maxrnd_10.txt, 02_maxrnd_11.txt, 02_maxrnd_12.txt, 02_maxrnd_13.txt, 02_maxrnd_14.txt, 02_maxrnd_15.txt, 02_maxrnd_16.txt, 02_maxrnd_17.txt, 02_maxrnd_18.txt, 02_maxrnd_19.txt, 03_increase_00.txt, 03_increase_01.txt, 03_increase_02.txt, 04_decrease_00.txt, 04_decrease_01.txt, 04_decrease_02.txt, 05_same_00.txt, 05_same_01.txt
Case Name Status Exec Time Memory
00_min.txt AC 22 ms 736 KB
00_sample_01.txt AC 23 ms 776 KB
00_sample_02.txt AC 21 ms 772 KB
00_sample_03.txt AC 21 ms 780 KB
00_sample_04.txt AC 20 ms 776 KB
00_sample_05.txt AC 23 ms 776 KB
01_rnd_00.txt AC 22 ms 772 KB
01_rnd_01.txt AC 21 ms 772 KB
01_rnd_02.txt AC 68 ms 768 KB
01_rnd_03.txt AC 22 ms 776 KB
01_rnd_04.txt AC 283 ms 776 KB
01_rnd_05.txt AC 207 ms 780 KB
01_rnd_06.txt AC 22 ms 772 KB
01_rnd_07.txt TLE 2034 ms 872 KB
01_rnd_08.txt TLE 2033 ms 840 KB
01_rnd_09.txt RE 0 ms 892 KB
02_maxrnd_00.txt TLE 2030 ms 884 KB
02_maxrnd_01.txt TLE 2029 ms 908 KB
02_maxrnd_02.txt TLE 2032 ms 904 KB
02_maxrnd_03.txt TLE 2031 ms 896 KB
02_maxrnd_04.txt TLE 2032 ms 848 KB
02_maxrnd_05.txt TLE 2031 ms 788 KB
02_maxrnd_06.txt TLE 2032 ms 896 KB
02_maxrnd_07.txt TLE 2031 ms 788 KB
02_maxrnd_08.txt TLE 2030 ms 796 KB
02_maxrnd_09.txt TLE 2032 ms 888 KB
02_maxrnd_10.txt TLE 2030 ms 896 KB
02_maxrnd_11.txt TLE 2038 ms 864 KB
02_maxrnd_12.txt TLE 2029 ms 896 KB
02_maxrnd_13.txt TLE 2033 ms 852 KB
02_maxrnd_14.txt TLE 2032 ms 900 KB
02_maxrnd_15.txt TLE 2033 ms 900 KB
02_maxrnd_16.txt TLE 2034 ms 852 KB
02_maxrnd_17.txt TLE 2031 ms 884 KB
02_maxrnd_18.txt TLE 2033 ms 892 KB
02_maxrnd_19.txt TLE 2033 ms 796 KB
03_increase_00.txt AC 24 ms 780 KB
03_increase_01.txt AC 23 ms 776 KB
03_increase_02.txt AC 22 ms 784 KB
04_decrease_00.txt TLE 2032 ms 896 KB
04_decrease_01.txt TLE 2032 ms 900 KB
04_decrease_02.txt TLE 2030 ms 788 KB
05_same_00.txt TLE 2031 ms 852 KB
05_same_01.txt RE 0 ms 884 KB