답안 #586595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586595 2022-06-30T12:19:12 Z blue Skyscraper (JOI16_skyscraper) C++17
5 / 100
2000 ms 212 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;
using vi = vector<int>;

const ll mod = 1'000'000'007LL;

ll ad(ll a, ll b)
{
	return (a+b) % mod;
}

int main()
{
	int N, L;
	cin >> N >> L;

	vi A(N);
	for(int i = 0; i < N; i++)
		cin >> A[i];

	sort(A.begin(), A.end());

	int f = 1;
	for(int i = 1; i <= N; i++)
		f = f * i;

	int res = 0;

	for(int z = 1; z <= f; z++)
	{
		next_permutation(A.begin(), A.end());

		int ct = 0;

		for(int i = 0; i+1 < N; i++)
			ct += abs(A[i] - A[i+1]);

		res += (ct <= L);
	}

	cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2053 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 2053 ms 212 KB Time limit exceeded
12 Halted 0 ms 0 KB -