Submission #888907

#TimeUsernameProblemLanguageResultExecution timeMemory
888907vjudge1Cryptography (NOI20_crypto)C++17
100 / 100
411 ms19580 KiB
#include <iostream> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> long long int a[300005], f[300005], mod = 1e9 + 7; int main() { int n; cin >> n; ordered_set s; for (int i = 1; i <= n; i++) { cin >> a[i]; s.insert(a[i]); } f[n + 1] = 1; for (int i = n; i >= 1; i--) { f[i] = f[i + 1] * (n - i + 1) % mod; } long long int res = 0; for (int i = 1; i <= n; i++) { res = (res + s.order_of_key(a[i]) * f[i + 1]) % mod; s.erase(s.find(a[i])); } cout << (res + 1) % mod; }
#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...