답안 #64538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64538 2018-08-04T20:14:24 Z reality Skyscraper (JOI16_skyscraper) C++17
100 / 100
216 ms 53492 KB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int dp[128][128][1024][3];
int s[128];
const int mod = 1e9 + 7;
void add(int &x,int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}
int pr(int x,int y) {
    return 1ll * x * y % mod;
}
int n,l;
int main(void) {
    cin>>n>>l;
    for (int i = 1;i <= n;++i)
        cin>>s[i];
    sort(s + 1,s + 1 + n);
    for (int i = n - 1;i;--i)
        s[i + 1] -= s[i];
    if (n == 1)
        return puts("1") * 0;
    dp[0][0][0][0] = 1;
    for (int i = 0;i < n;++i)
        for (int j = 0;j <= i;++j)
            for (int k = 0;k <= l;++k)
                for (int t = 0;t < 3;++t) {
                    int ns = k + s[i + 1] * (2 * j - t);
                    const int C = dp[i][j][k][t];
                    if (ns > l)
                        continue;
                    add(dp[i + 1][j + 1][ns][t],pr(j + 1 - t,C));
                    add(dp[i + 1][j][ns][t],pr(2 * j - t,C));
                    if (j > 0)
                        add(dp[i + 1][j - 1][ns][t],pr(j - 1,C));
                    add(dp[i + 1][j + 1][ns][t + 1],pr(2 - t,C));
                    if (!(j == 1 && t == 1) || i == n - 1)
                    add(dp[i + 1][j][ns][t + 1],pr(2 - t,C));
                }
    int ans = 0;
    for (int i = 0;i <= l;++i)
        add(ans,dp[n][1][i][2]);
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 1084 KB Output is correct
6 Correct 3 ms 1168 KB Output is correct
7 Correct 3 ms 1168 KB Output is correct
8 Correct 3 ms 1168 KB Output is correct
9 Correct 4 ms 1168 KB Output is correct
10 Correct 3 ms 1168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1372 KB Output is correct
2 Correct 4 ms 1372 KB Output is correct
3 Correct 4 ms 1628 KB Output is correct
4 Correct 4 ms 1628 KB Output is correct
5 Correct 5 ms 1628 KB Output is correct
6 Correct 4 ms 1628 KB Output is correct
7 Correct 4 ms 1628 KB Output is correct
8 Correct 4 ms 1680 KB Output is correct
9 Correct 4 ms 1680 KB Output is correct
10 Correct 3 ms 1680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 1084 KB Output is correct
6 Correct 3 ms 1168 KB Output is correct
7 Correct 3 ms 1168 KB Output is correct
8 Correct 3 ms 1168 KB Output is correct
9 Correct 4 ms 1168 KB Output is correct
10 Correct 3 ms 1168 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1628 KB Output is correct
14 Correct 4 ms 1628 KB Output is correct
15 Correct 5 ms 1628 KB Output is correct
16 Correct 4 ms 1628 KB Output is correct
17 Correct 4 ms 1628 KB Output is correct
18 Correct 4 ms 1680 KB Output is correct
19 Correct 4 ms 1680 KB Output is correct
20 Correct 3 ms 1680 KB Output is correct
21 Correct 9 ms 5020 KB Output is correct
22 Correct 187 ms 39216 KB Output is correct
23 Correct 208 ms 43900 KB Output is correct
24 Correct 191 ms 53492 KB Output is correct
25 Correct 216 ms 53492 KB Output is correct
26 Correct 164 ms 53492 KB Output is correct
27 Correct 84 ms 53492 KB Output is correct
28 Correct 82 ms 53492 KB Output is correct
29 Correct 183 ms 53492 KB Output is correct
30 Correct 187 ms 53492 KB Output is correct