ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187395 | #3360. 平流层 | gaojieming | 100 | 1330ms | 32604kb | C++11 | 1.4kb | 2023-10-02 09:14:37 | 2023-10-02 12:43:35 |
answer
#include<bits/stdc++.h>
#define ll long long
#define il inline
#define pn putchar('\n')
#define maxint 2147483647
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define maxn 2005
#define mod 1000000007
#define int ll
using namespace std;
int n,ans;
int a[maxn],b[maxn][maxn],f[maxn],tmp[maxn],jc[maxn];
il void upd(int &x,int y)
{
x+=y;
if(x>=mod)
x-=mod;
if(x<0)
x+=mod;
}
il int lowbit(int x)
{
return x&-x;
}
il void cha(int x,int y,int ad)
{
for(int i=y;i<=n;i+=lowbit(i))
upd(b[x][i],ad);
}
il int fi(int x,int y)
{
int ret=0;
for(int i=y;i;i-=lowbit(i))
upd(ret,b[x][i]);
return ret;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
scanf("%lld",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]),tmp[i]=a[i];
jc[0]=1;
for(int i=1;i<=n;i++)
jc[i]=jc[i-1]*i%mod;
sort(tmp+1,tmp+1+n);
unique(tmp+1,tmp+1+n);
for(int i=1;i<=n;i++)
a[i]=lower_bound(tmp+1,tmp+1+n,a[i])-tmp;
for(int i=1;i<=n;i++)
{
for(int j=n;j>1;j--)
{
int ret=fi(j-1,a[i]);
cha(j,a[i],ret);
upd(f[j],ret);
}
cha(1,a[i],1);
f[1]++;
}
for(int i=1;i<=n;i++)
f[i]=f[i]*jc[n-i]%mod;
for(int i=1;i<=n;i++)
upd(ans,(f[i]-f[i+1]*(i+1))%mod);
printf("%lld",ans);
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1248kb
input:
10 17555697 225663153 267317961 109938115 578806141 659739421 597281665 103951030 285251051 665433007
output:
1705200
result:
ok 1 number(s): "1705200"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1312kb
input:
20 148673729 214138063 773748492 429742369 518386254 36549786 994000561 34025703 245586467 11014966 ...
output:
961183142
result:
ok 1 number(s): "961183142"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1312kb
input:
20 125700499 49877433 545019865 25974157 146562491 243078247 33157873 862046 102327617 319430449 741...
output:
734923693
result:
ok 1 number(s): "734923693"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1440kb
input:
50 203355196 240741761 103379395 202624021 100651153 51985981 230209487 22795390 542308147 83728240 ...
output:
197711954
result:
ok 1 number(s): "197711954"
Test #5:
score: 10
Accepted
time: 0ms
memory: 1440kb
input:
50 97557433 437622250 710153719 490650643 100103821 106489501 245850839 5586480 87354994 290984773 1...
output:
78152083
result:
ok 1 number(s): "78152083"
Test #6:
score: 10
Accepted
time: 2ms
memory: 2336kb
input:
200 270643392 135304417 144281539 372498366 209757209 272673665 9564626 1857915 259416652 848449105 ...
output:
471268010
result:
ok 1 number(s): "471268010"
Test #7:
score: 10
Accepted
time: 2ms
memory: 2332kb
input:
200 95889842 170687735 10067452 386564879 66872751 609235478 219724111 410544610 455881145 58054231 ...
output:
822134882
result:
ok 1 number(s): "822134882"
Test #8:
score: 10
Accepted
time: 462ms
memory: 32604kb
input:
2000 333042033 8632305 185264779 66850597 193864292 727122089 619418801 333933441 81568018 115238801...
output:
752595768
result:
ok 1 number(s): "752595768"
Test #9:
score: 10
Accepted
time: 442ms
memory: 32600kb
input:
2000 618394981 674787201 211801591 292766483 178438177 88914685 43640701 36529996 1985026 231619538 ...
output:
123817981
result:
ok 1 number(s): "123817981"
Test #10:
score: 10
Accepted
time: 422ms
memory: 32604kb
input:
2000 180607521 505596955 35467225 117714401 279778969 310205233 1305965 6349817 597988441 444613118 ...
output:
688678729
result:
ok 1 number(s): "688678729"