Submission #1113810

#TimeUsernameProblemLanguageResultExecution timeMemory
1113810AvianshCryptography (NOI20_crypto)C++17
35 / 100
300 ms26896 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; long long fac[300005]; long long mod = 1e9+7; signed main(){ ios::sync_with_stdio(0); cin.tie(0); fac[1]=1; for(long long i = 2;i<=3e5;i++){ fac[i]=fac[i-1]*i; fac[i]%=mod; } long long n; cin >> n; long long arr[n]; ordered_set pts; for(long long i = 0;i<n;i++){ cin >> arr[i]; pts.insert(arr[i]); } long long ans = 0; for(long long i = 0;i<n;i++){ ans+=1LL*pts.order_of_key(arr[i])*fac[n-i-1]; ans%=mod; pts.erase(arr[i]); } ans++; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...