답안 #44355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44355 2018-03-31T17:05:10 Z iletavcioski Calvinball championship (CEOI15_teams) C++17
100 / 100
394 ms 1428 KB
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int n;
    cin>>n;
    vector<int> v;
    vector<ll> dp(n+1,1);
    vector<ll> dpmax(n+1,0);

    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        v.push_back(a);
        dpmax[i]=a;
        if(i)
            dpmax[i]=max(dpmax[i],dpmax[i-1]);
    }
    ll brojac=1;
    ll maxi=0;
    for(int i=n-1;i>=0;i--)
    {
        int a;
        if(i==0)
            a=0;
        else
            a=dpmax[i-1];
        for(int j=1;j<v[i];j++)
        {
            brojac+=dp[max(a,j)];
            brojac%=mod;
        }
        for(int j=1;j<=i;j++)
        {
            dp[j]=1LL*j*dp[j]+dp[j+1];
            dp[j]%=mod;
        }
    }
    cout<<brojac<<endl;
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:27:8: warning: unused variable 'maxi' [-Wunused-variable]
     ll maxi=0;
        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 752 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 764 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 888 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 888 KB Output is correct
3 Correct 4 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 3 ms 888 KB Output is correct
3 Correct 6 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 394 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1208 KB Output is correct
2 Correct 30 ms 1208 KB Output is correct
3 Correct 100 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 1216 KB Output is correct
2 Correct 125 ms 1216 KB Output is correct
3 Correct 390 ms 1428 KB Output is correct