QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#677112 | #7879. Colorful Balloons | i0stream | WA | 2ms | 7060kb | C++14 | 487b | 2024-10-26 09:55:27 | 2024-10-26 09:55:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int n;
string s[N];
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++){
cin>>s[i];
}
s[0]="";
sort(s+1,s+n+1);
string mx="";int cur=1,tms=1;
for (int i=1;i<=n;i++){
if (s[i]==s[i-1]){
cur++;
continue;
}
if (cur>tms){
tms=cur;
mx=s[i-1];
}
cur=1;
}
if (cur>tms){
tms=cur;
mx=s[n];
}
if (tms>n/2) cout<<mx<<endl;
else puts("uh-oh");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7060kb
input:
5 red green red red blue
output:
red
result:
ok "red"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7052kb
input:
3 red blue yellow
output:
uh-oh
result:
ok "uh-oh"
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 6792kb
input:
1 abc
output:
result:
wrong answer Unexpected EOF in the participants output