답안 #244573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244573 2020-07-04T09:58:31 Z dantoh000 Calvinball championship (CEOI15_teams) C++14
100 / 100
219 ms 564 KB
///happy birthday errorgorn
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000007;
typedef long long ll;
int n;
int a[10005];
ll dp[2][10005];
int mx[10005];
ll ans = 0;
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        mx[i] = max(mx[i-1],a[i]);
    }
    for (int i = 1; i <= n; i++){
        dp[0][i] = 1;
    }
    for (int i = 1; i < n; i++){
        for (int j = 1; j <= n; j++){
            dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
            dp[i&1][j] %= mod;
        }
        ans += (a[n-i]-1)*dp[i&1][mx[n-i-1]];
        ans %= mod;
    }
    ans = (ans+a[n])%mod;
    printf("%lld",ans);

}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:22:32: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                               ~^~
teams.cpp:22:47: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                                              ~^~
teams.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
teams.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 10 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 205 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 384 KB Output is correct
2 Correct 64 ms 384 KB Output is correct
3 Correct 54 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 512 KB Output is correct
2 Correct 210 ms 512 KB Output is correct
3 Correct 219 ms 564 KB Output is correct