답안 #154233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154233 2019-09-19T11:47:12 Z mhy908 Calvinball championship (CEOI15_teams) C++14
0 / 100
4 ms 632 KB
#include <bits/stdc++.h>
#define mod 1000007
using namespace std;
typedef long long LL;
int n;
int arr[10010], maxx;
int newp[10010];
LL dp[10010], dp2[10010];
LL temp=0;
int t2;
LL power(LL a, LL b)
{
    if(b==0)return 1;
    LL ret=power(a, b/2);
    if(b%2)return ret*ret%mod*a%mod;
    return ret*ret%mod;
}
int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
        maxx=max(maxx, arr[i]);
        newp[i]=maxx;
    }
    dp[n+1]=dp2[n+1]=1;
    t2=n+1;
    for(int i=n; i>=1; i--){
        if(newp[i-1]==newp[i]){
            temp+=(LL)(arr[i]-1)*power((LL)newp[i], (LL)t2-(LL)i-1);
            temp%=mod;
        }
        else{
            temp+=(LL)(arr[i]-1)*power((LL)newp[i], (LL)t2-(LL)i-1);
            temp%=mod;
            dp[i]=(temp*dp2[t2]+dp[t2])%mod;
            dp2[i]=power((LL)newp[i], min((LL)t2, (LL)n)-(LL)i+1)*dp2[t2]%mod;
            t2=i;
            temp=0;
        }
    }
    printf("%lld", dp[1]);
}
// 16603

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 4 ms 624 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 4 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -