Submission #570220

#TimeUsernameProblemLanguageResultExecution timeMemory
570220OspleiMountains (NOI20_mountains)C++17
66 / 100
2075 ms6672 KiB
#include <bits/stdc++.h> using namespace std; vector <long long int> v, aux; int main() { long long int n, a, c=0, md=0, mi=0; bool sorted=true; cin >> n; for (long long int i=0; i<n; i++){ cin >> a; v.push_back(a); aux.push_back(a); } sort (aux.begin(), aux.end()); for (int i=0; i<n; i++) if (v[i]!=aux[i]) sorted = false; if (sorted==true) { cout << 0; return 0; } for (long long int y=1; y<n-1; y++){ for (int i=y-1; i>=0; i--) if (v[i]<v[y]) mi++; if (mi!=0){ for (int i=y+1; i<n; i++) if (v[i]<v[y]) md++; c+=mi*md; mi=0; md=0; } } cout << c; }
#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...