답안 #54987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54987 2018-07-05T16:44:44 Z kdh9949 Calvinball championship (CEOI15_teams) C++17
100 / 100
193 ms 876 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 10001, M = 1000007;

int n, r, a[N], m[N], d[2][N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", a + i);
        m[i] = max(m[i - 1], a[i]);
    }
    fill(d[0], d[0] + N, 1);
    r = a[n];
    for(int i = n - 1, p = 1; i >= 1; i--, p ^= 1){
        for(int j = 1; j <= i; j++)
            d[p][j] = (d[!p][j + 1] + 1LL * j * d[!p][j]) % M;  
        r = (r + 1LL * (a[i] - 1) * d[p][m[i - 1]]) % M;
    }
    printf("%d\n", r % M);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:11: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 560 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 3 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 560 KB Output is correct
2 Correct 3 ms 572 KB Output is correct
3 Correct 3 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 3 ms 572 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 580 KB Output is correct
2 Correct 2 ms 580 KB Output is correct
3 Correct 3 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 580 KB Output is correct
2 Correct 3 ms 580 KB Output is correct
3 Correct 4 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 580 KB Output is correct
2 Correct 3 ms 580 KB Output is correct
3 Correct 3 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 756 KB Output is correct
2 Correct 36 ms 756 KB Output is correct
3 Correct 42 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 756 KB Output is correct
2 Correct 193 ms 876 KB Output is correct
3 Correct 149 ms 876 KB Output is correct