ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196744 | #2353. Group | wosile | 100 | 622ms | 392008kb | C++11 | 453b | 2023-10-31 08:37:09 | 2023-10-31 12:06:35 |
answer
#define mod 1000007
#include<bits/stdc++.h>
using namespace std;
int dp[10005][10005];
int n;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)dp[n][i]=1;
for(int i=n-1;i>=1;i--)for(int j=1;j<=n;j++)dp[i][j]=(1LL*j*dp[i+1][j]+dp[i+1][j+1])%mod;
int ans=0;
int mx=0;
for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
for(int j=1;j<x;j++)ans=(dp[i][max(mx,j)]+ans)%mod;
mx=max(mx,x);
}
printf("%d",(ans+1)%mod);
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
8 1 1 1 2 3 2 2 2
output:
149
result:
ok 1 number(s): "149"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1244kb
input:
14 1 1 1 1 1 2 3 3 4 3 2 4 3 4
output:
83699
result:
ok 1 number(s): "83699"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1612kb
input:
97 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 3...
output:
855408
result:
ok 1 number(s): "855408"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1628kb
input:
100 1 1 1 1 2 1 1 3 4 3 2 2 2 1 4 1 4 1 5 3 1 5 2 2 3 3 4 5 1 2 5 1 1 1 1 5 3 3 3 5 1 2 3 2 4 5 3 4 ...
output:
304377
result:
ok 1 number(s): "304377"
Test #5:
score: 10
Accepted
time: 2ms
memory: 4176kb
input:
500 1 2 3 3 1 3 3 2 2 1 2 3 1 3 3 2 2 1 1 1 1 4 3 2 1 1 2 4 2 1 5 2 1 1 6 7 8 4 1 1 4 3 5 2 9 3 7 2 ...
output:
36970
result:
ok 1 number(s): "36970"
Test #6:
score: 10
Accepted
time: 0ms
memory: 9088kb
input:
1000 1 1 2 2 1 1 1 2 2 2 1 3 1 1 3 2 1 2 3 1 1 3 3 1 3 1 3 1 3 3 2 1 3 1 4 2 1 3 5 1 6 5 2 2 3 6 4 2...
output:
346685
result:
ok 1 number(s): "346685"
Test #7:
score: 10
Accepted
time: 381ms
memory: 386268kb
input:
9853 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35...
output:
783930
result:
ok 1 number(s): "783930"
Test #8:
score: 10
Accepted
time: 53ms
memory: 118824kb
input:
5000 1 1 2 1 3 2 1 1 1 2 1 1 1 3 2 3 2 1 1 2 2 2 3 4 5 2 1 4 6 5 2 4 3 6 2 3 3 5 4 2 6 7 3 2 2 6 4 4...
output:
780874
result:
ok 1 number(s): "780874"
Test #9:
score: 10
Accepted
time: 186ms
memory: 392008kb
input:
10000 1 2 3 4 4 4 1 3 4 4 1 4 5 4 3 5 5 3 3 2 6 5 5 1 1 3 4 3 4 4 2 1 3 7 5 7 3 8 6 6 6 4 8 7 3 3 5 ...
output:
393798
result:
ok 1 number(s): "393798"
Test #10:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
3 1 2 3
output:
5
result:
ok 1 number(s): "5"
Extra Test:
score: 0
Extra Test Passed