# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
457824 | 2021-08-07T12:11:58 Z | vanic | Calvinball championship (CEOI15_teams) | C++14 | 972 ms | 472 KB |
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; const int maxn=1e4+5, mod=1e6+7, Log=20; int n; int dp[2][maxn]; inline int sum(int a, int b){ if(a+b>=mod){ return a+b-mod; } if(a+b<0){ return a+b+mod; } return a+b; } inline int mul(int a, int b){ return (ll)a*b%mod; } int a[maxn]; int pref[maxn]; int main(){ scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%d", a+i); } int sol=1; bool tren=0; for(int i=0; i<maxn; i++){ dp[1][i]=1; } pref[0]=1; for(int i=0; i<n; i++){ pref[i+1]=max(pref[i], a[i]); } for(int i=n-1; i>-1; i--){ sol=sum(sol, mul(a[i]-1, dp[tren^1][pref[i]])); for(int j=0; j<maxn-1; j++){ dp[tren][j]=sum(mul(j, dp[tren^1][j]), dp[tren^1][j+1]); } tren^=1; } printf("%d\n", sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 332 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 372 KB | Output is correct |
2 | Correct | 10 ms | 372 KB | Output is correct |
3 | Correct | 10 ms | 372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 332 KB | Output is correct |
2 | Correct | 49 ms | 356 KB | Output is correct |
3 | Correct | 53 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 99 ms | 360 KB | Output is correct |
2 | Correct | 99 ms | 332 KB | Output is correct |
3 | Correct | 97 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 955 ms | 420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 475 ms | 396 KB | Output is correct |
2 | Correct | 502 ms | 412 KB | Output is correct |
3 | Correct | 490 ms | 420 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 942 ms | 428 KB | Output is correct |
2 | Correct | 972 ms | 460 KB | Output is correct |
3 | Correct | 964 ms | 472 KB | Output is correct |