# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
737738 |
2023-05-07T16:25:31 Z |
lalig777 |
Izbori (COCI22_izbori) |
C++14 |
|
3000 ms |
1536 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
82 ms |
212 KB |
Output is correct |
4 |
Correct |
80 ms |
300 KB |
Output is correct |
5 |
Correct |
81 ms |
316 KB |
Output is correct |
6 |
Correct |
27 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
82 ms |
212 KB |
Output is correct |
4 |
Correct |
80 ms |
300 KB |
Output is correct |
5 |
Correct |
81 ms |
316 KB |
Output is correct |
6 |
Correct |
27 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
3070 ms |
340 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3044 ms |
1536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
82 ms |
212 KB |
Output is correct |
4 |
Correct |
80 ms |
300 KB |
Output is correct |
5 |
Correct |
81 ms |
316 KB |
Output is correct |
6 |
Correct |
27 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
3070 ms |
340 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |