#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> st;
const ll mod = 998244353;
const ll mxn = 3e5+10;
ll fac[mxn];
int arr[mxn];
inline ll mad(ll a,ll b){
a += b;
return a>=mod?a-mod:a;
}
inline ll mub(ll a,ll b){
return mad(a,mod-b);
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
fac[0] = 1;
for(int i = 1;i<mxn;i++)fac[i] = fac[i-1]*i%mod;
int N;
cin>>N;
for(int i = 1;i<=N;i++){
cin>>arr[i];
st.insert(arr[i]);
}
ll ans = 0;
for(int i = 1;i<=N;i++){
ans = mad(ans,fac[N-i]*st.order_of_key(arr[i])%mod);
st.erase(arr[i]);
}
cout<<mad(ans,1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Correct |
2 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Correct |
2 ms |
3672 KB |
Output is correct |
3 |
Correct |
3 ms |
3688 KB |
Output is correct |
4 |
Correct |
2 ms |
3800 KB |
Output is correct |
5 |
Correct |
3 ms |
3688 KB |
Output is correct |
6 |
Correct |
2 ms |
3688 KB |
Output is correct |
7 |
Correct |
2 ms |
3688 KB |
Output is correct |
8 |
Correct |
2 ms |
3820 KB |
Output is correct |
9 |
Correct |
2 ms |
3688 KB |
Output is correct |
10 |
Correct |
2 ms |
3688 KB |
Output is correct |
11 |
Correct |
3 ms |
3688 KB |
Output is correct |
12 |
Correct |
2 ms |
3688 KB |
Output is correct |
13 |
Correct |
2 ms |
3688 KB |
Output is correct |
14 |
Correct |
2 ms |
3696 KB |
Output is correct |
15 |
Correct |
2 ms |
3816 KB |
Output is correct |
16 |
Correct |
2 ms |
3676 KB |
Output is correct |
17 |
Correct |
2 ms |
3676 KB |
Output is correct |
18 |
Correct |
2 ms |
3676 KB |
Output is correct |
19 |
Correct |
2 ms |
3804 KB |
Output is correct |
20 |
Correct |
2 ms |
3676 KB |
Output is correct |
21 |
Correct |
2 ms |
3676 KB |
Output is correct |
22 |
Correct |
2 ms |
3676 KB |
Output is correct |
23 |
Correct |
2 ms |
3672 KB |
Output is correct |
24 |
Correct |
2 ms |
3676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Incorrect |
227 ms |
20956 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3928 KB |
Output is correct |
2 |
Incorrect |
229 ms |
19796 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Incorrect |
4 ms |
4184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Correct |
2 ms |
3672 KB |
Output is correct |
3 |
Correct |
3 ms |
3688 KB |
Output is correct |
4 |
Correct |
2 ms |
3800 KB |
Output is correct |
5 |
Correct |
3 ms |
3688 KB |
Output is correct |
6 |
Correct |
2 ms |
3688 KB |
Output is correct |
7 |
Correct |
2 ms |
3688 KB |
Output is correct |
8 |
Correct |
2 ms |
3820 KB |
Output is correct |
9 |
Correct |
2 ms |
3688 KB |
Output is correct |
10 |
Correct |
2 ms |
3688 KB |
Output is correct |
11 |
Correct |
3 ms |
3688 KB |
Output is correct |
12 |
Correct |
2 ms |
3688 KB |
Output is correct |
13 |
Correct |
2 ms |
3688 KB |
Output is correct |
14 |
Correct |
2 ms |
3696 KB |
Output is correct |
15 |
Correct |
2 ms |
3816 KB |
Output is correct |
16 |
Correct |
2 ms |
3676 KB |
Output is correct |
17 |
Correct |
2 ms |
3676 KB |
Output is correct |
18 |
Correct |
2 ms |
3676 KB |
Output is correct |
19 |
Correct |
2 ms |
3804 KB |
Output is correct |
20 |
Correct |
2 ms |
3676 KB |
Output is correct |
21 |
Correct |
2 ms |
3676 KB |
Output is correct |
22 |
Correct |
2 ms |
3676 KB |
Output is correct |
23 |
Correct |
2 ms |
3672 KB |
Output is correct |
24 |
Correct |
2 ms |
3676 KB |
Output is correct |
25 |
Correct |
2 ms |
3676 KB |
Output is correct |
26 |
Incorrect |
4 ms |
4184 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3928 KB |
Output is correct |
2 |
Incorrect |
229 ms |
19796 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Correct |
2 ms |
3672 KB |
Output is correct |
3 |
Correct |
3 ms |
3688 KB |
Output is correct |
4 |
Correct |
2 ms |
3800 KB |
Output is correct |
5 |
Correct |
3 ms |
3688 KB |
Output is correct |
6 |
Correct |
2 ms |
3688 KB |
Output is correct |
7 |
Correct |
2 ms |
3688 KB |
Output is correct |
8 |
Correct |
2 ms |
3820 KB |
Output is correct |
9 |
Correct |
2 ms |
3688 KB |
Output is correct |
10 |
Correct |
2 ms |
3688 KB |
Output is correct |
11 |
Correct |
3 ms |
3688 KB |
Output is correct |
12 |
Correct |
2 ms |
3688 KB |
Output is correct |
13 |
Correct |
2 ms |
3688 KB |
Output is correct |
14 |
Correct |
2 ms |
3696 KB |
Output is correct |
15 |
Correct |
2 ms |
3816 KB |
Output is correct |
16 |
Correct |
2 ms |
3676 KB |
Output is correct |
17 |
Correct |
2 ms |
3676 KB |
Output is correct |
18 |
Correct |
2 ms |
3676 KB |
Output is correct |
19 |
Correct |
2 ms |
3804 KB |
Output is correct |
20 |
Correct |
2 ms |
3676 KB |
Output is correct |
21 |
Correct |
2 ms |
3676 KB |
Output is correct |
22 |
Correct |
2 ms |
3676 KB |
Output is correct |
23 |
Correct |
2 ms |
3672 KB |
Output is correct |
24 |
Correct |
2 ms |
3676 KB |
Output is correct |
25 |
Correct |
2 ms |
3676 KB |
Output is correct |
26 |
Incorrect |
227 ms |
20956 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |