답안 #143026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143026 2019-08-12T16:01:36 Z Ruxandra985 Calvinball championship (CEOI15_teams) C++14
20 / 100
425 ms 648 KB
#include <cstdio>
#include <iostream>
#include <cstring>
#define DIMN 10010
#define MOD 1000000007
using namespace std;
int v[DIMN],maxi_now[DIMN];
long long s[2][DIMN];
int main()
{
  //  FILE *fin = fopen ("a.in","r");
  //  FILE *fout = fopen ("a.out","w");
  //  freopen ("a.in" , "r" , stdin);
  //  freopen ("a.out" , "w" , stdout);
    int n,i,lin,j;
    scanf ("%d",&n);
    for (i=1;i<=n;i++){
        scanf ("%d",&v[i]);
        maxi_now[i] = max ( maxi_now[i-1] , v[i] );
    }

    /// secv e de forma : prefix comun  , v[i]-1 , orice respecta

    long long sol = 0;

    for (i=0;i<=n;i++)
        s[0][i] = 1;

    for (i=1;i<n;i++){
        lin = (i&1);
        for (j=0;j<=n;j++){
            s[lin][j] = (s[1-lin][j+1] + (s[1-lin][j] * j)%MOD)%MOD;
        }
        /// sufixul pe care il modificam are lungimea i
        /// schimbi n-i ca sa scada lexicografic
        sol = (sol + (s[lin][maxi_now[n-i-1]] * (v[n-i] - 1)%MOD)%MOD);
        memset (s[1-lin] , 0 , sizeof(s[1-lin]));
    }


    printf ("%lld" , (sol + v[n])%MOD);
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:16:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d",&n);
     ~~~~~~^~~~~~~~~
teams.cpp:18:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d",&v[i]);
         ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 414 ms 648 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 116 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 425 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -