Submission #34246


Source Code Expand

Copy
#include<iostream>
using namespace std;
int a[50],b[60],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{
		int s=b[mi];
		b[mi]=a[p];
		mm=fi(p+1);
		b[mi]=s;
		for(i=p+1;i<n;+i){
			if(a[p]<a[i]&&a[i]<=b[mi])
				break;
		}
		if(i<n){
			b[i]=a[p];
			mm=min(mn,fi(p+1));
			b[i]=100001;
		}
	}
	return mm;
}
int main(){
	int i;
	cin>>n;
	for(i=0;i<n;++i)
		cin>>a[i];
	fill(b,b+55,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 734 Byte
Status TLE
Exec Time 2032 ms
Memory 904 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 5
TLE × 33
RE × 6
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 21 ms 784 KB
00_sample_01.txt RE 0 ms 904 KB
00_sample_02.txt TLE 2029 ms 892 KB
00_sample_03.txt TLE 2029 ms 888 KB
00_sample_04.txt AC 22 ms 784 KB
00_sample_05.txt TLE 2029 ms 892 KB
01_rnd_00.txt TLE 2029 ms 896 KB
01_rnd_01.txt RE 0 ms 892 KB
01_rnd_02.txt TLE 2029 ms 896 KB
01_rnd_03.txt TLE 2031 ms 900 KB
01_rnd_04.txt TLE 2031 ms 896 KB
01_rnd_05.txt TLE 2031 ms 888 KB
01_rnd_06.txt RE 0 ms 904 KB
01_rnd_07.txt TLE 2029 ms 896 KB
01_rnd_08.txt TLE 2029 ms 896 KB
01_rnd_09.txt TLE 2031 ms 900 KB
02_maxrnd_00.txt TLE 2031 ms 892 KB
02_maxrnd_01.txt RE 0 ms 900 KB
02_maxrnd_02.txt TLE 2030 ms 896 KB
02_maxrnd_03.txt TLE 2030 ms 868 KB
02_maxrnd_04.txt TLE 2031 ms 904 KB
02_maxrnd_05.txt TLE 2031 ms 904 KB
02_maxrnd_06.txt RE 0 ms 896 KB
02_maxrnd_07.txt TLE 2030 ms 900 KB
02_maxrnd_08.txt TLE 2030 ms 896 KB
02_maxrnd_09.txt TLE 2031 ms 792 KB
02_maxrnd_10.txt TLE 2031 ms 904 KB
02_maxrnd_11.txt TLE 2032 ms 900 KB
02_maxrnd_12.txt TLE 2030 ms 900 KB
02_maxrnd_13.txt TLE 2030 ms 900 KB
02_maxrnd_14.txt TLE 2031 ms 900 KB
02_maxrnd_15.txt TLE 2030 ms 900 KB
02_maxrnd_16.txt TLE 2029 ms 904 KB
02_maxrnd_17.txt TLE 2030 ms 848 KB
02_maxrnd_18.txt TLE 2031 ms 904 KB
02_maxrnd_19.txt TLE 2030 ms 888 KB
03_increase_00.txt AC 24 ms 764 KB
03_increase_01.txt AC 22 ms 784 KB
03_increase_02.txt AC 23 ms 736 KB
04_decrease_00.txt TLE 2030 ms 896 KB
04_decrease_01.txt RE 0 ms 892 KB
04_decrease_02.txt TLE 2030 ms 888 KB
05_same_00.txt TLE 2031 ms 900 KB
05_same_01.txt TLE 2029 ms 888 KB