답안 #143034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143034 2019-08-12T16:29:26 Z Ruxandra985 Calvinball championship (CEOI15_teams) C++14
100 / 100
456 ms 760 KB
/// vreau sa ma impusc puneam MOD 10^9 + 7 nu pot sa cred....

#include <cstdio>
#include <iostream>
#include <cstring>
#define DIMN 10010
#define MOD 1000007
using namespace std;
long long 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);
    long long n,i,lin,j;
    scanf ("%lld",&n);
    for (i=1;i<=n;i++){
        scanf ("%lld",&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:19:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%lld",&n);
     ~~~~~~^~~~~~~~~~~
teams.cpp:21:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%lld",&v[i]);
         ~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 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 504 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 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 508 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 508 KB Output is correct
2 Correct 10 ms 488 KB Output is correct
3 Correct 10 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 436 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 504 KB Output is correct
2 Correct 123 ms 632 KB Output is correct
3 Correct 123 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 632 KB Output is correct
2 Correct 451 ms 708 KB Output is correct
3 Correct 456 ms 760 KB Output is correct