제출 #951204

#제출 시각아이디문제언어결과실행 시간메모리
951204NourWaelCryptography (NOI20_crypto)C++17
100 / 100
422 ms27032 KiB
#include <bits/extc++.h> #define int long long using namespace std; using namespace __gnu_pbds; int const mxN = 3e5+5; int const mod = 1e9+7; int perm[mxN], a[mxN]; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; perm[1] = 1; for(int i=2; i<=n; i++) perm[i] = (perm[i-1] * i) % mod; tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st; for(int i=0; i<n; i++) { cin>>a[i]; st.insert(a[i]); } int ans = 0; for(int i=0; i<n; i++) { int t = st.order_of_key(a[i]); ans += (t*perm[n-i-1])%mod; ans%=mod; st.erase(a[i]); } cout<<(ans+1)%mod; 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...