Submission #958022

#TimeUsernameProblemLanguageResultExecution timeMemory
958022Zena_HossamCryptography (NOI20_crypto)C++14
14 / 100
582 ms60176 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define ll int using namespace std; namespace __gnu_pbds { typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; } using namespace __gnu_pbds; #define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //#define ll double #define ll1 long long #define F first #define S second #define sz size() #define all(s) s.begin(),s.end() #define all1(s) s.rbegin(),s.rend() ll mod=1e9+7; int main() { fi //freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout); //cin>>T;ll oo=0; ll n; cin>>n; map<ll,ll>m,d,dd; ll o=1; for(ll i=1;i<=n;i++){ o=(i*o)%mod; m[i]=o; } ll arr[n],a[n]; for(ll i=0;i<n;i++){ cin>>a[i]; arr[i]=a[i]; } sort(a,a+n); for(ll i=0;i<n;i++){ d[a[i]]=i+1; } for(ll i=1;i<=n;i++){ dd[d[arr[i-1]]]=i; } ll k[n+5]={};ll c=0; ordered_set q; for(ll i=1;i<=n;i++){ //cout<<i-q.order_of_key(dd[i])-1<<" "; c+=m[(n-dd[i])]*(i-1-q.order_of_key(dd[i]));q.insert(dd[i]); }cout<<(c+1)%mod; }

Compilation message (stderr)

Crypto.cpp: In function 'int main()':
Crypto.cpp:51:8: warning: unused variable 'k' [-Wunused-variable]
   51 |     ll k[n+5]={};ll c=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...