# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638001 | Do_you_copy | Skyscraper (JOI16_skyscraper) | C++17 | 1 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());
ll min(const ll &a, const ll &b){
return (a < b) ? a : b;
}
ll max(const ll &a, const ll &b){
return (a > b) ? a : b;
}
const ll Mod = 1000000007;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 1e2 + 10;
const int maxL = 1e3 + 10;
int n, L;
int a[maxN];
ll dp[maxN][maxN][maxL][3];
void Init(){
cin >> n >> L;
a[n] = 1e7;
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a, a + n);
dp[0][0][0][0] = 1;
for (int i = 1; i <= n; ++i){
for (int j = 1; j <= i; ++j){
for (int k = 0; k <= L; ++k){
for (int m = 0; m <= 2; ++m){
ll delta = (2 * j - m) * (a[i] - a[i - 1]);
if (delta > k|| i + j + 1 - m > n) continue;
dp[i][j][k][m] += dp[i - 1][j - 1][k - delta][m];
if (m > 0){
dp[i][j][k][m] += (3 - m) * dp[i - 1][j - 1][k - delta][m - 1];
if (m == 1) dp[i][j][k][m] += 2 * j * dp[i - 1][j][k - delta][m - 1];
else if (m == 2 && i == n) dp[i][j][k][m] += dp[i - 1][j][k - delta][m - 1];
else dp[i][j][k][m] += (j - 1) * dp[i - 1][j][k - delta][m - 1];
}
dp[i][j][k][m] += (2 * j - m) * dp[i - 1][j][k - delta][m];
if (m == 2 && i == n) dp[i][j][k][m] += dp[i - 1][j + 1][k - delta][m];
else if (m == 2) dp[i][j][k][m] += j * (j - 1) * dp[i - 1][j + 1][k - delta][m];
else if (m == 1) dp[i][j][k][m] += j * j * dp[i - 1][j + 1][k - delta][m];
else dp[i][j][k][m] += j * (j + 1) * dp[i - 1][j + 1][k - delta][m];
dp[i][j][k][m] %= Mod;
}
}
}
}
ll ans = 0;
for (int i = 0; i <= L; ++i){
ans += dp[n][1][i][2];
ans %= Mod;
}
cout << ans;
}
#define debu
#define taskname "test"
signed main(){
if (fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
#ifdef debug
freopen(taskname".out", "w", stdout);
#endif
}
faster;
ll tt = 1;
//cin >> tt;
while (tt--){
Init();
}
if (fopen("timeout.txt", "r")){
ofstream timeout("timeout.txt");
timeout << 1000 * double(clock()) / CLOCKS_PER_SEC;
#ifndef debug
cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n";
#endif
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |