답안 #93590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93590 2019-01-09T23:08:17 Z abood101 Calvinball championship (CEOI15_teams) C++17
0 / 100
1000 ms 688 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
int const N=1e4+1,oo=1e9,M=1e6;
ll const OO=1e18;
double const eps=1e-6,PI=acos(-1);
int mod=M+7;

int n,aa[N],dp[2][N][2],dp1[2][N];

int main(){
  	scanf("%d",&n);
    int mx=0;
    for(int i=0;i<n;i++){
      scanf("%d",&aa[i]);
      mx=max(mx,aa[i]);
    }
    int f=0,an=0;
    dp1[f][1]=1;
    dp[f][1][0]=1;
    for(int i=1,un=1;i<n;i++){
        f=1-f;
        un=max(un,aa[i]);
        dp[f][un][0]=1;
        for(int j=1;j<=i+1&&j<mx;j++){
            dp1[f][j]=(dp1[!f][j]*1LL*j+dp1[!f][j-1])%mod;
            dp[f][j][1]=(dp[!f][j][1]*1LL*j+dp[!f][j][0]*1LL*min(j,aa[i]-1)+dp[!f][j-1][1])%mod;
        }
        dp[f][mx][1]=(dp[!f][mx][1]*1LL*mx+dp[!f][mx][0]*1LL*min(mx,aa[i]-1)+dp[!f][mx-1][1])%mod;
    }
    for(int i=1;i<mx;i++){
        an+=dp1[f][i];
        an%=mod;
    }
    an+=dp[f][mx][1]+1;
    an%=mod;
  	printf("%d\n",mx);
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:15:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&n);
    ~~~~~^~~~~~~~~
teams.cpp:18:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&aa[i]);
       ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 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 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 688 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -