답안 #1105515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105515 2024-10-26T15:56:33 Z akzytr Skyscraper (JOI16_skyscraper) C++17
5 / 100
2000 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/*
	n <= 8
	Check all possible permutations
*/
int main() {
	int N, L;
	cin >> N >> L;
	int a[N];
	for(int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);

	ll count = 0;
	do {
		ll dif = 0;
		for(int i = 1; i < N; i++) {
			dif += abs(a[i] - a[i - 1]);
		}
		if(dif <= L) {
			count++;
		}
	} while(next_permutation(a, a + N));
	cout << count << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2066 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Execution timed out 2066 ms 512 KB Time limit exceeded
12 Halted 0 ms 0 KB -