Submission #245692

# Submission time Handle Problem Language Result Execution time Memory
245692 2020-07-07T08:03:31 Z yasseenkamel Skyscraper (JOI16_skyscraper) C++14
5 / 100
2000 ms 384 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>

using namespace std;

typedef int in;
#define int long long
const long double EPS=1e-9;
const int MOD=1e9+7;
const int N=1e6;

int n,m,a[105];

bool ok(){
	int sm = 0;
	for(int i = 0 ; i < n - 1 ; i ++){
		sm += abs(a[i] - a[i + 1]);
	}
	return sm <= m;
}

in main(){
	cin >> n >> m;
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	sort(a,a + n);
	int ans = 0;
	do{
		ans += ok();
	}
	while(next_permutation(a,a + n));
	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Execution timed out 2077 ms 384 KB Time limit exceeded
12 Halted 0 ms 0 KB -