답안 #873338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873338 2023-11-14T21:05:59 Z bobbilyking Calvinball championship (CEOI15_teams) C++17
0 / 100
42 ms 65536 KB
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include<bits/stdc++.h>
#include<math.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;

#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = (l); i < r; ++i)

#define NN 10010
#define M 1000007 // 998244353

ll dp[NN][NN];

int main(){
//    freopen("a.in", "r", stdin);
//    freopen("a.out", "w", stdout);

    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(20);
    
    fill(dp[0], dp[0]+NN, 1ll);
    F(i, 1, NN) F(l, 1, NN-1) {
        dp[i][l] = (l * dp[i-1][l] + dp[i-1][l+1])%M; 
    }

    ll mx = 1;
    ll answer = 1;
    G(n) for (ll left = n-1; left >= 0; --left) {
        G(x)
        if (x <= mx) {
            // max didn't change, so normal
            answer = (answer + (x-1) * dp[left][mx])%M;
        } else {
            // max changes at the last second; 
            assert(mx + 1 == x);
            answer = (answer + mx * dp[left][mx])%M;
        }
        mx = max(mx, x);

        
    }
    cout << answer << '\n';

    
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -