Submission #570192

#TimeUsernameProblemLanguageResultExecution timeMemory
570192kamilamartinezMountains (NOI20_mountains)C++14
70 / 100
2090 ms7164 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector <ll> unos; int main() { ll n, i, cont=0, a, b, j, uc=0, cc=0; cin >> n; ll xd[n], ceros[n]; bool lol=false, kk=false; for(i=0;i<n;i++) { cin >> xd[i]; if(xd[i-1]>xd[i]) lol=true; if(xd[i]!=0 && xd[i]!=1) kk=true; if(xd[i]==1) uc++, unos.push_back(i); if(xd[i]==0) cc++; ceros[i]=cc; } if(lol==false) { cout << "0" << endl; return 0; } if(kk==false) { for(i=0;i<uc;i++) { if(unos[i]!=0 && unos[i]!=n-1) { cont+=ceros[unos[i]]*(cc-ceros[unos[i]]); } } cout << cont << endl; return 0; } for(i=1;i<n-1;i++) { a=0; b=0; for(j=0;j<i;j++) { if(xd[j]<xd[i]) a++; } for(j=i+1;j<n;j++) { if(xd[j]<xd[i]) b++; } cont+=a*b; } cout << cont << endl; 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...