제출 #154204

#제출 시각아이디문제언어결과실행 시간메모리
154204arnold518Calvinball championship (CEOI15_teams)C++14
100 / 100
263 ms764 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e4;
const ll MOD = 1e6+7;

int N, A[MAXN+10], B[MAXN+10];
ll dp[3][MAXN+10], ans;

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);
    for(i=1; i<=N; i++) B[i]=max(B[i-1], A[i]);

    for(j=1; j<=N; j++) dp[0][j]=1;
    ans+=A[N]-1;
    for(i=1; i<=N; i++)
    {
        for(j=1; j<=N; j++)
        {
            dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
            dp[i&1][j]%=MOD;
        }
        for(j=1; j<A[N-i]; j++) ans+=dp[i&1][max(j, B[N-i-1])];
        ans%=MOD;
    }
    printf("%lld", ans+1);
}

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'int main()':
teams.cpp:28:28: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
                           ~^~
teams.cpp:28:43: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j]=dp[i-1&1][j]*j+dp[i-1&1][j+1];
                                          ~^~
teams.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
teams.cpp:19:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &A[i]);
                         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...