답안 #210781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210781 2020-03-18T10:52:57 Z johutha Calvinball championship (CEOI15_teams) C++14
80 / 100
1000 ms 764 KB
#include <iostream>
#include <vector>
#include <algorithm>
 
#define int int64_t
#define MOD (int)(1e6+7)
 
using namespace std;
 
signed main()
{
    int n;
    cin >> n;
 
    vector<int> ip(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ip[i];
    }
 
    vector<int> dp(n + 1);
    vector<int> st(n + 1);
    st[0] = 1;
    vector<int> oldst;
 
    int last = n;
    int res = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        int mmax = 0;
        for (int j = 0; j < i; j++) mmax = max(mmax, ip[j]);
 
        for (int j = last; j >= mmax + 1; j--)
        {
            oldst = st;
            dp = vector<int>(n + 1, 0);
            st = vector<int>(n + 1, 0);
            st[0] = 1;
            for (int i = 1; i <= n; i++)
            {
                dp[i] = (dp[i - 1] + oldst[i - 1]) * j;
                st[i] = dp[i - 1] + oldst[i - 1];
                dp[i] %= MOD;
                st[i] %= MOD;
            } /*
            cerr << j << ": ";
            for (int i = 0; i <= n; i++)
            {
                cout << dp[i] << " ";
            }
            cout << "   ";
            for (int i = 0; i <= n; i++)
            {
                cout << st[i] << " ";
            }
            cout << "   ";
            for (int i = 0; i <= n; i++)
            {
                cout << oldst[i] << " ";
            } */
        }
 
        // cout << "\n";
        last = mmax;
 
        int base = ip[i] - 1;
        for (int j = n - i - 1; j >= 0; j--)
        {
            // cerr << i << " " << j << " " << base << "\n";
            res += base*st[j];
            base *= mmax;
            base %= MOD;
            res %= MOD;
        }
    }
    cout << (res + 1) << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 296 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 276 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 6 ms 276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 376 KB Output is correct
2 Correct 26 ms 404 KB Output is correct
3 Correct 28 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1043 ms 636 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 552 KB Output is correct
2 Correct 538 ms 504 KB Output is correct
3 Correct 518 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 764 KB Time limit exceeded
2 Halted 0 ms 0 KB -