답안 #1070945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070945 2024-08-22T21:34:05 Z vjudge1 Calvinball championship (CEOI15_teams) C++17
100 / 100
239 ms 944 KB
#include<bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef pair<char, int> ci;
typedef pair<string, int> si;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
#define pb push_back
#define fi first
#define se second
#define whole(v) v.begin(), v.end()
#define rwhole(v) v.rbegin(), v.rend()
#define inf INT_MAX/2
#define fro front

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<ll> x;
    ll ma = -1;
    vector<ll> g;
    for(int i = 0; i < n; ++i){
        ll j; cin >> j;
        g.pb(j);
        if(j > ma){
            x.pb(ma);
            ma = j;
            continue;
        }
        x.pb(ma);
    }
    vector<ll> a(n+1, 1);
    vector<ll> b(n+1);
    vector<ll> z(n+1);
    for(int i = n-1; i >= 0; --i){
        for(int j = 0; j <= n; ++j){
            ll sum = 0;
            sum += 1LL * j * a[j] % 1000007;
            sum += a[j+1] % 1000007;
            b[j] = sum;
            if(j == x[i]){
                z[i] += a[x[i]];
                z[i] %= 1000007;
                //cout << a[x[i]] << endl;
            }
        }
        a = b;
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        z[i] *= g[i]-1;
        z[i] %= 1000007;
        ans += z[i];
        ans %= 1000007;
    }
    cout << (ans+1) % 1000007 << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 660 KB Output is correct
2 Correct 57 ms 604 KB Output is correct
3 Correct 63 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 920 KB Output is correct
2 Correct 237 ms 860 KB Output is correct
3 Correct 236 ms 944 KB Output is correct