답안 #163305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163305 2019-11-12T14:13:14 Z dantoh000 Calvinball championship (CEOI15_teams) C++14
0 / 100
227 ms 636 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000007;
int main(){
    int n; scanf("%d",&n);
    int a[n];
    int k[n];
    for (int i = 0; i < n; i++) {
        scanf("%d",&a[i]);
        if (i) k[i] = max(k[i-1],a[i]);
        else k[i] = a[i];
    }
    ll ct[2][n+1];
    ll ans = a[n-1];
    for (int i = 1; i < n; i++){
        ct[0][i] = 1;
    }
    ct[0][n] = ct[1][n] = 0;
    for (int j = 1; j < n; j++){
        ct[j%2][1] = ct[1-j%2][1];
        for (int i = 2; i < n; i++){
            ct[j%2][i] = (i-1)*ct[1-j%2][i]+ct[1-j%2][i+1];
            ct[j%2][i] %= mod;
        }
        //printf("adding %d %d\n",a[n-j-1]-1,ct[j%2][k[n-j-1]]);
        ans += (a[n-j-1]-1)*ct[j%2][k[n-j-1]];
        ans %= mod;
    }
    printf("%d",ans);

}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:30:20: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
     printf("%d",ans);
                    ^
teams.cpp:6:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d",&n);
            ~~~~~^~~~~~~~~
teams.cpp:10: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 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 223 ms 636 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -