Submission #737738

#TimeUsernameProblemLanguageResultExecution timeMemory
737738lalig777Izbori (COCI22_izbori)C++14
10 / 110
3070 ms1536 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool win(int l, int r, vector<int>&lista){ int p=r-l+1; vector<int>copia(p); for (int i=0; i<p; i++) copia[i]=lista[l+i]; sort(copia.begin(), copia.end()); int count=1, maxi=0, ant=copia[0]; for (int i=1; i<p; i++){ if (copia[i]!=ant){ maxi=max(maxi, count); count=1; ant=copia[i]; }else count++; }if (maxi<count) maxi=count; if (maxi*2>p) return true; else return false; } int main(){ int n; cin>>n; vector<int>lista(n); int ans=n; for (int i=0; i<n; i++) cin>>lista[i]; for (int i=0; i<n; i++){ for (int j=i+1; j<n; j++){ if (win(i, j, lista)) ans++; } }cout<<ans<<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...