QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641343 | #46. Pirates | test123 | 50 ✓ | 0ms | 3976kb | C++14 | 586b | 2024-10-14 20:01:52 | 2024-10-14 20:01:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int n;
char ch[maxn];
int num[26];
int main(){
n=read();
scanf("%s",ch+1);
for(int i=1;i<=n;++i) num[ch[i]-'a']++;
int mx=0;
for(int i=0;i<26;++i){
if(num[i]>mx){
mx=num[i];
}
}
for(int i=0;i<26;++i){
if(num[i]==mx){
putchar('a'+i);
printf(" %d\n",num[i]);
break;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 2.5
Accepted
time: 0ms
memory: 3916kb
input:
1 a
output:
a 1
result:
ok single line: 'a 1'
Test #2:
score: 2.5
Accepted
time: 0ms
memory: 3908kb
input:
50 hpdoypydsjjbrflbqehxgvyyyqhtzsawrlpfgpwztepgsapffw
output:
p 6
result:
ok single line: 'p 6'
Test #3:
score: 2.5
Accepted
time: 0ms
memory: 3968kb
input:
50 ekxzicouuxfoaafacrevbzrkjqnzauhcguihkntnilgiphgase
output:
a 5
result:
ok single line: 'a 5'
Test #4:
score: 2.5
Accepted
time: 0ms
memory: 3928kb
input:
50 lwqahlveuyleogcdgpshnkeqkmlrnctvymyjuablpvgnitclxo
output:
l 6
result:
ok single line: 'l 6'
Test #5:
score: 2.5
Accepted
time: 0ms
memory: 3788kb
input:
50 ygrmrrfkwbkorubwjxqxzeprbtfuhlvvrpqznkuhvjbokuqtsr
output:
r 7
result:
ok single line: 'r 7'
Test #6:
score: 2.5
Accepted
time: 0ms
memory: 3932kb
input:
50 pqntqusybvefkspypzqoqspqzimkmlkknhzmbwaafjdyemvcvg
output:
q 5
result:
ok single line: 'q 5'
Test #7:
score: 2.5
Accepted
time: 0ms
memory: 3872kb
input:
100 zmcydqewcegjhihditaigyjdcfskgispkutzqbbdhfegynhbrtrnopvfpengixwvzvjriiaabzawgqwoxkvdsqteylruefuiyhcn
output:
i 8
result:
ok single line: 'i 8'
Test #8:
score: 2.5
Accepted
time: 0ms
memory: 3788kb
input:
100 owkfuohimmfmajqcnoljqcipvrzvrfkifyqjjuxqqqfagclhsyltvfqtlbysgmtuvqsuwaesuyujakfxpthjuojyaaqollepmcpb
output:
q 9
result:
ok single line: 'q 9'
Test #9:
score: 2.5
Accepted
time: 0ms
memory: 3928kb
input:
200 kvirktyytcmbfwsabtbqfzvilpfsgshteqydzprftopcwwswcrnehokavyjscjpaeyqmhokqfsqntjpbvpuievovrfgkwpwepdoiwygybrghatskyfxezfrbhzkbulbvwwrgielieisetpwkgsmkolyttljcbifbawcvcmnvnjakwyothqzlfljlxmmlgbxieldgqdhl
output:
w 12
result:
ok single line: 'w 12'
Test #10:
score: 2.5
Accepted
time: 0ms
memory: 3972kb
input:
201 fzyivvcgrjqwwzgxhpjivechkodbwpsxjczeokztzmzdefiymyozyqmbveexafysklcdmnockyxsqxonxtaghhlzqmowiabteggbtlxyirzybxomvlchicnfpeanepalzndmcktkzchdiodcrfkiktowdlfrivjrjpetlpivdzbeggykmvkepfrrvvhozsisqkchgmlmj
output:
z 13
result:
ok single line: 'z 13'
Test #11:
score: 2.5
Accepted
time: 0ms
memory: 3792kb
input:
500 irtdljupgnqevbfzxdtwgogixkuucukrzgliqrfmbapiagzrlufjrnsdzrxzfmpbhazzjuahdrfqrwghpwbdgugozuqmjyapibqrwckaggqcxglpvmlufkjghxfaggzekmmkazjhbzrvnhfzofqrrrgvighqkhgdkmvvimakmfqrppckzkljqhzksolkclureqqadczvnezxkcigroshbgbtnftkgqmywsomimrtnazdldficdmkskbrdtsuhnzhzlfipgbvarwirvznkwmzbyaabiecxrmxhkstbplw...
output:
z 28
result:
ok single line: 'z 28'
Test #12:
score: 2.5
Accepted
time: 0ms
memory: 3908kb
input:
2 aa
output:
a 2
result:
ok single line: 'a 2'
Test #13:
score: 2.5
Accepted
time: 0ms
memory: 3968kb
input:
500 lknpfgrsbgkhtiqbervsfpjqhlsohirospfwtsdqxajhdlhcqdxqbfaiqfjbovenbigxreehxdviloprpvdbkcaogkvtrqacieirxfwxypkcsbumaulhoaqnghvgrkhkrioxihczovooeqsianwkffagmgmadvffnaemvarsfdhmrxcwwcssclgahzuhpjkxrzdfljajsghlsjcvzekilegfaioddntzatwudwtxsugyhelutshdslchiymhmkebinngpbqtpybktjyaepjuvgauqzsijbnbrqezifte...
output:
a 27
result:
ok single line: 'a 27'
Test #14:
score: 2.5
Accepted
time: 0ms
memory: 3844kb
input:
3 xyy
output:
y 2
result:
ok single line: 'y 2'
Test #15:
score: 2.5
Accepted
time: 0ms
memory: 3976kb
input:
3 aba
output:
a 2
result:
ok single line: 'a 2'
Test #16:
score: 2.5
Accepted
time: 0ms
memory: 3784kb
input:
10 ktuonxnmrf
output:
n 2
result:
ok single line: 'n 2'
Test #17:
score: 2.5
Accepted
time: 0ms
memory: 3844kb
input:
10 tjsgrjpndc
output:
j 2
result:
ok single line: 'j 2'
Test #18:
score: 2.5
Accepted
time: 0ms
memory: 3788kb
input:
10 ktkyfdttcc
output:
t 3
result:
ok single line: 't 3'
Test #19:
score: 2.5
Accepted
time: 0ms
memory: 3912kb
input:
10 bbatscqewm
output:
b 2
result:
ok single line: 'b 2'
Test #20:
score: 2.5
Accepted
time: 0ms
memory: 3928kb
input:
10 eptazubsuj
output:
u 2
result:
ok single line: 'u 2'