Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
# -*- coding: utf-8 -*- # @Date : 2018-10-02 08:00:37 # @Author : raj lath ([email protected]) # @Link : link # @Version : 1.0.0 from sys import stdin max_val=int(10e12) min_val=int(-10e12) def read_int() : return int(stdin.readline()) def read_ints() : return [int(x) for x in stdin.readline().split()] def read_str() : return input() def read_strs() : return [x for x in stdin.readline().split()] lens = read_int() strs = read_str() ans = lens // 11 print(min(ans, strs.count("8")))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios ::sync_with_stdio(0); cin.tie(0); long long int j = 0, n; cin >> n; string s; cin >> s; for (long long int i = 0; i <= n - 1; i++) { if (s[i] == '8') { j++; } } n = n / 11; if (n <= j) { cout << n << endl; } else cout << j << endl; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
a=int(input()) b=input() d=[] if b.count('8')>1: k=1 else: k=0 if a>=11 and b.count('8')>0: for i in range(a): if b[i]!='8' and b[i] not in d: d.append(b[i]) k+=1 print(min((a//11),(a//k),b.count('8'))) else: print(0)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n = int(raw_input()) s = raw_input() ls = len([c for c in s if c == '8']) print min(ls, n // 11)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; public class phonenumbers { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String bafry = sc.next(); int[] digits = new int[n]; int bayus = 0; for (int i = 0; i < n; i++) { digits[i] = Integer.parseInt(bafry.substring(i,i+1)); if (digits[i] == 8) { bayus++; } } Arrays.sort(digits); int bobib = Math.min(bayus, n/11); System.out.println(bobib); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
k = int(input()) n = list(map(int,input())) kv = n.count(8) print(kv if kv < k // 11 else k//11)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
input() string=input() print(min(str.count(string,"8"),len(string)//11))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class PhoneNumbers3 { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static StringTokenizer st; public static void main(String[] args) throws IOException { int n = nextInt(); String s = nextString(); int m = 0; for (int i = 0; i < n; i++) if (s.charAt(i) == '8') m++; System.out.println(Math.min(m, n/11)); } public static String nextLine() throws IOException { return in.readLine(); } public static String nextString() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine()); return st.nextToken(); } public static int nextInt() throws IOException { return Integer.parseInt(nextString()); } public static long nextLong() throws IOException { return Long.parseLong(nextString()); } public static int[] intArray(int n) throws IOException { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public static int[][] intArray(int n, int m) throws IOException { int[][] a = new int[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = nextInt(); return a; } public static long[] longArray(int n) throws IOException { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) a=list(map(int,list(input()))) c8=a.count(8) t=n//11 if(t>=c8): print(c8) else: print(t)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; public class PhoneNumbers{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String st = sc.next(); if(n < 11){ System.out.println("0"); } else{ int count = 0; for(int i = 0;i<n;i++){ if(st.charAt(i) == '8'){ count++; } } int i = n/11; if(count >= i) System.out.println(i); else if(count < i) System.out.println(count); } } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
x = int(input()) s = input() if x < 11: print("0") else: x1 = x//11 c = s.count('8') if c < x1: print(c) else: print(x1)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() k=0 if('8' in s): d=s.count('8') if(d>=1): while(n>=11 and d>0): k+=1 d-=1 n-=11 print(k) #100 #88202862851852449384524 #88887088871457098945874 #486988698468788381417332 #842888928188688887641132194956 #22 #0011223344556677889988 #11 #00000000008 #11 #31415926535
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = input() def solve(n, s): c = s.count('8') while c: if c + 10*c <= n: return c c -= 1 return c print(solve(n,s))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) a = str(input()) count = 0 for item in a: if item == "8": count += 1 print(int(min(n/11, count)))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = eval(input()) c = input() i =0 count =0 temp=0 for j in range(n): if c[j] == "8": i+=1 if i ==0: print(0) else: while count < i and temp+11<=n: temp+=11 count+=1 print(count)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; int main() { int n; scanf("%d", &n); string s; cin >> s; int maxPhone = n / 11; int eight = 0; for (auto& c : s) if (c == '8') eight++; printf("%d\n", min(maxPhone, eight)); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
from collections import Counter as c n = int(input()) a = input() if n>=11: eight = c(a) op = int(n/11) if eight["8"]>=op: print(op) elif eight["8"]<op: print(eight["8"]) else: print(0) else: print(0)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n = input() str = raw_input() a = str.count('8') if n<11 or a == 0: print (0) elif n>=11: c = n/11 if a>c: print c else: print a
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = input() numbers = input() eights = 0 max_nums = len(numbers)//11 for n in numbers: if n == '8': eights += 1 if eights >= max_nums: print(max_nums) else: print(eights)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
def phone_numbers(): n = int(input()) s = input() if (n // 11 == 0): print(0) return 0 k = 0 for i in range(0, n): if (s[i] == "8"): k += 1 if (k == n // 11): print(k) return 0 if (k == 0): print(0) else: print(k) return 0 phone_numbers()
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, b = 0; char c; cin >> n; for (int i = 0; i < n; i++) { cin >> c; if (c == '8') b++; } cout << min(b, n / 11) << endl; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
from collections import Counter EIGHT = '8' def solve(n, s): counts = Counter(s) r = 0 while counts[EIGHT]: d = 10 counts[EIGHT] -= 1 for k, v in counts.items(): if k != EIGHT: e = min(d, v) d -= e counts[k] -= e e = min(d, counts[EIGHT]) d -= e counts[EIGHT] -= e if d > 0: break r += 1 return r n = int(input()) s = input() print(solve(n, s))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
import sys digits = int(input()) num = input() total = 0 for i in range(len(num)): if total == digits//11: print(total) sys.exit() if num[i] == '8': total += 1 continue print(total)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = input() c = s.count("8") print(min(n//11,c))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
a = int(input()) S = input() L = a//11 P = S.count("8") print(min(L, P))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() k=0 for e in s: if e=='8': k=k+1 r=n-k a=r//10 if a>k: print(k) else: print(n//11)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() count=s.count('8') m=n//11 print(min(count,m))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int a = n / 11, d = 0; for (int i = 0; i < n; i++) { if (s[i] == '8') { d++; } } cout << min(d, a); }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java .util.*; public class a{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String x=sc.next(); int arr[]=new int[10]; Arrays.fill(arr,0); for(int i=0;i<n;i+=1){ if(x.charAt(i)=='8') arr[9]++; else if(x.charAt(i)=='9') arr[8]++; else arr[x.charAt(i)-'0']++; } int ans=0; int c=0; while(true){ if(make(arr)) c++; else { System.out.println(c); return; } } } static boolean make(int arr[]){ if(arr[9]==0) return false; arr[9]--; int count=10; for(int i=0;i<10;i++){ if(arr[i]<count){ count-=arr[i]; arr[i]=0; } else{ arr[i]-=count; count=0; } } if(count==0) return true; return false; } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() s=list(s) c=s.count("8") if n//11<=c: print(n//11) elif c==0: print(c) elif n//11>c: print(c)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); string s; cin >> s; int c = 0; for (int i = 0; i < n; i++) { if (s[i] == '8') { c++; } } int ss = 0; for (int i = c; i > 0; i--) { if ((n >= (11 * i))) { ss = i; break; } } cout << ss << endl; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.Scanner; public class Prob { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int cnt = 0; for (int i = 0; i < n; i++) { if (s.charAt(i) == '8') cnt++; } int res = 0; for (int i = 1; i <= cnt; i++) { if ((n - i) / 10 >= i) res = i; } System.out.println(res); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); String str = sc.next(); int numof8 = 0; int count = 0; for(int i=0;i<str.length();i++){ int temp = Integer.parseInt(String.valueOf(str.charAt(i))); if(temp == 8) numof8++; count++; } //System.out.println("numof8 : " + numof8 + " count :" + count); if(numof8 == 0){ System.out.println(0); return; } count /= 11; int res = Math.min(count, numof8); System.out.println(res); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) m = input() s = 0 for i in range(n): if(m[i] == "8"): s+=1 print(min(n//11, s))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
(function () { var eights = 0; var n=parseInt(readline()); for (var ch of readline()) if (ch === '8') eights++; print(Math.min(n / 11>>0, eights)) }());
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) k = str(input()) q = 0 for i in k: if i == "8": q += 1 if (len(k) - len(k) % 11) / 11 > q: print(q) else: print(int((len(k) - len(k) % 11) / 11))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc= new Scanner(System.in); int n=sc.nextInt(); String s= sc.next(); int x=0; for(int i=0;i<n;i++){ if(s.charAt(i)=='8') x++; } // cout << min(8,n/11); int ans=Math.min(x,n/11); System.out.println(ans); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) a = [*map(int, input())] e = a.count(8) print(min(n//11, e))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, ans; string s; int main() { scanf("%d", &n); cin >> s; for (int i = 0; i < s.size(); ++i) if (s[i] == '8') { ++ans; } if (s.size() / 11 < ans) { ans = s.size() / 11; } printf("%d", ans); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n = raw_input() s = raw_input() n = len(s) k1 = s.count('8') k2 = n - k1 v = 0 for i in range(1, k1+1): v = max(v, min(i, (n-i)//10)) print(v)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() m=s.count('8') print(min(n//11,m))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) # ns=[int(x)for x in input().split()] s=input() nums=[0]*2 for c in s: if ord(c)-ord('0')==8: nums[0]+=1 else: nums[1]+=1 def fetch10(): if sum(nums)<10: return False if nums[1]>=10: nums[1]-=10 else: nums[0]-=(10-nums[1]) nums[1]=0 def fetch11(): if nums[0]<=0: return False nums[0]-=1 if fetch10()==False: return False return True ans=0 while fetch11(): ans+=1 print(ans)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using LL = long long; int main() { int n; scanf("%d", &n); char s[100 + 5]; scanf("%s", s); int cnt[10] = {}; for (int i = 0; i < n; ++i) cnt[s[i] - '0']++; printf("%d\n", std::min(cnt[8], n / 11)); }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = input() for i in range(n, -1, -1): if s.count('8') < i: continue if (len(s) - i) // 10 < i: continue print(i) break
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, ans = 0; cin >> n; string s; cin >> s; for (long long i = 0; i < s.length(); i++) { if (s[i] == '8') ans++; } cout << min(n / 11, ans); }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() print(int(min((s.count('8'),n/11))))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
import math from collections import defaultdict def input_ints(): return list(map(int, input().split())) def solve(): n = int(input()) s = input() n = len(s) c = s.count('8') for x in range(100): if x > c or 11 * x > n: print(x - 1) return if __name__ == '__main__': solve()
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) a=input() print(min(n//11,a.count("8")))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; public class Solution { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); char[] s = sc.next().toCharArray(); int cnt = 0; for (char c : s) if (c == '8') cnt++; System.out.println(Math.min(cnt, n / 11)); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
a = raw_input() a = raw_input() print min(len(a)/11,a.count("8"))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
from collections import Counter n = int(input().strip()) s = input().strip() z = Counter(s) if '8' not in s or n<11: print(0) else: c=n//11 if z['8']>=c: print(c) else: print(z['8'])
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n=[int(k) for k in raw_input().split(" ")][0] s=raw_input() n8=0 for k in s: if k=="8": n8+=1 res= min(n8,n/11) print res
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n=input() s=raw_input() ni=n/11 ss=s.count('8') print min(ni,ss)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=str(input()) a=n//11 c=s.count("8") print(min(a,c))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) l=input() l=list(l) a=l.count("8") if a<=len(l)//11: print(a) elif a>=len(l)//11: print(len(l)//11) else: print("0")
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, c; c = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '8') { c += 1; } } cout << min(n / 11, c); }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int l; int cnt = 0; cin >> l; char num[11]; for (int i = 0; i < 11; i++) { num[i] = 0; } char s[l + 1]; cin >> s; int ar[10] = {0}; for (int i = 0; i < l; i++) { ar[s[i] - 48]++; } while (l > 0) { if (ar[8] > 0) { ar[8]--; l--; if (l >= 10) { cnt++; l -= 10; } } else { break; } } cout << cnt; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) a=input() b=a.count('8') c=n//11 if b==0 or n<11: print(0) elif b<=c: print(b) else: print(c)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
nnn = int(input()) n = input() c8 = n.count('8') print(min(c8, nnn//11))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
// Submitted by Subhash Yadav import java.io.*; import java.util.*; public class A { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n=sc.nextInt(); char c[]=sc.next().toCharArray(); int cnt=0; for(char c1:c) { if(c1=='8') cnt++; } System.out.println(Math.min(cnt, n/11)); } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
def calc(): print() def main(): n: int = int(input()) num: str = input().strip() tmp: int = n // 11 print(min(num.count('8'), tmp)) if __name__ == '__main__': main()
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n = int(raw_input()) s = raw_input() eights = [c for c in s if c=='8'] ans =0 if len(eights)>0: ans = min( n/11, len(eights)) print ans
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = input() e = s.count('8') a = 0 while e > 0 and n > 10: e -= 1 n -= 11 a += 1 print(a)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
l=int(input()) s=input() frq={8:0,0:0} for c in s: if c!='8': frq[0]=frq[0]+1 else: frq[8]=frq[8]+1 l=0 r=10 while r>l+1: m=(l+r)//2 if frq[8]-m>=0 and (frq[0]+frq[8]-m)//10>=m: l=m else: r=m print(l)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
def main(): length = int(input()) cards = input() n_eights = cards.count('8') max_numbers = length // 11 print(min(n_eights, max_numbers)) if __name__ == '__main__': main()
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> int main(void) { int N; int num[2] = {}; int result = 0; char temp[101]; scanf("%d", &N); scanf("%s", temp); for (int i = 0; i < N; i++) { if (temp[i] == '8') num[0]++; else num[1]++; } while (num[0] >= 1 && num[0] + num[1] >= 11) { num[0]--; if (num[1] >= 10) num[1] -= 10; else { num[0] -= 10 - num[1]; num[1] = 0; } result++; } printf("%d\n", result); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) a=input() b=n//11 c=a.count("8") print(min(b,c))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char S[105]; int main() { int N, M, i, j, k, ans = 0; scanf("%d", &N); scanf("%s", S); for (i = 0; i < N; i++) { ans += ((S[i] - '0') == 8); } printf("%d\n", min(ans, N / 11)); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() res1=0 res2=0 l='8' if l not in s or n<11: print(0) else: res1=s.count(l) res2=n//11 print(min(res1, res2))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
from collections import Counter n=input() s=raw_input() c1=Counter(s) n=n/11 print min(n,c1['8'])
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) S = input() print(min(S.count('8'), n // 11))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) m=input() res=0 eig=m.count("8") while n>=11 and eig>0: if n>=11 and eig>0: res+=1 eig-=1 n-=11 else: break print(res)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) cs = input() eights = sum(1 for c in cs if c == '8') print(min(len(cs) // 11, eights))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=list(str(input())) res1=0 res2=0 l='8' if l not in s or n<11: print(0) else: res1=s.count(l) res2=n//11 print(min(res1, res2))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) s=input() eight=0 other=0 for i in s: if i=='8': eight+=1 else: other+=1 z=0 a= eight+other while 0<eight and 0<a: eight-=1 num=1 while num<11 and 0<other: other-=1 num+=1 while num<11 and 0<eight: eight-=1 num+=1 if num==11: z+=1 a=eight+other print(z)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
from sys import stdin n = int(stdin.readline()) a = stdin.readline().strip() print min(n/11,a.count('8'))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.Scanner; /** * Created by Abid on 04/10/2018. */ public class prob1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n; n = input.nextInt(); //System.out.println(n); String str; str = input.next(); int count = 0; for(int i = 0; i< str.length(); i++){ if(str.charAt(i) == '8'){ count++; } } int count2 = n/11; if(count>count2){ System.out.println(count2); } else { System.out.println(count); } } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n=input() a=raw_input() if 22>len(a)>=11 and a.count("8")>0: print 1 elif len(a)>=22: print int(min(len(a)/11,a.count("8"))) else: print 0
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
""" Phone Numbers """ n = int(input()) nString = input() eights = nString.count('8') strings = n //11 print(strings if(strings <= eights) else eights)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int count = 0, size; cin >> size; char c; vector<char> num; for (int i = 0; i < size; i++) { cin >> c; num.push_back(c); } for (int i = 0; i < num.size(); i++) { if (num[i] == '8') count++; if ((size / 11) < count) count = (size / 11); } cout << count << endl; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.Scanner; public class PhoneNumbers { public static void main(String[] args) { Scanner s=new Scanner(System.in); int loop = s.nextInt(), counter=0, all=0; String str=s.next(); int size=str.length(); for(int i=0; i<str.length(); i++) { if(str.charAt(i)=='8') counter++; } for(int i=0; i<str.length();i++) { if(size<11) break; all++; size-=11; } if(counter>=all) System.out.println(all); else if(all>counter) System.out.println(counter); else if(counter!=0) System.out.println(all); else System.out.println(0); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n=input() s=list(raw_input()) ei=s.count('8') num=n/11 print min(num,ei)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve() { int n, c = 0; cin >> n; bool flag = false; string s; cin >> s; for (int i = 0; i < n; ++i) { if (s[i] == '8') { flag = true; c++; } } if (!flag) cout << "0\n"; else cout << min(c, n / 11) << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tc = 1; while (tc--) { solve(); } return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python2
n = int(raw_input()) nos = n / 11 count = 0 s = raw_input() for i in s: if i == '8': count += 1 print min(nos, count)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> inline int gi() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * f; } char S[110]; int main() { int n = gi(), s = 0; scanf("%s", S + 1); for (int i = 1; i <= n; ++i) if (S[i] == '8') ++s; printf("%d\n", std::min(s, n / 11)); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, cnt; char str[110]; int main() { scanf("%d %s", &n, str + 1); for (int i = 1; i <= n; i++) if (str[i] == '8') cnt++; for (int i = cnt; i >= 1; i--) if ((n - i) / 10 >= i) return !printf("%d\n", i); puts("0"); return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; char x[2]; scanf("%d", &a); gets(x); char s[a + 1]; gets(s); if (a < 11) printf("0"); else { for (int i = 0; i < a; i++) { if (s[i] == '8') c++; } if ((a / 11) <= c) printf("%d\n", a / 11); else printf("%d", c); } return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) nums = input() cnt = nums.count('8') n//=11 print(min(cnt, n))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) str = input() res = 0 much = str.count("8") while n >= 11: if much > 0: n -= 11 much -= 1 res += 1 else: break print(res)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char S[11000]; int n, Ans; inline int Min(register int A, register int B) { return A < B ? A : B; } int main() { scanf("%d%s", &n, S + 1); for (register int i = 1; i <= n; i++) Ans += (S[i] == '8'); printf("%d\n", Min(n / 11, Ans)); }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = input() if '8' in s and len(s) >= 11: count_8 = s.count('8') num = min(count_8,len(s)//11) print(num) else: print(0)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const double EPS = 1e-9; const double PI = acos(-1.); const int INF = 1e9; const long long MOD = 1e9 + 7; const int MAXN = 1e5 + 5; char s[MAXN]; void solve() { int n; scanf("%d%s", &n, &s[0]); int cnt8 = 0; for (int i = (0); i < (int)(n); i++) { if (s[i] == '8') { cnt8++; } } int ans = min(cnt8, n / 11); printf("%d\n", ans); } int main() { int t = 1; while (t--) { solve(); } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int i, k, c = 0; cin >> i; char a[100]; for (k = 0; k < i; k++) { cin >> a[k]; } for (k = 0; k < i; k++) { if (a[k] == '8') c++; } if (c >= i / 11) { cout << i / 11 << endl; } else if (c == 1 && i >= 11) { cout << 1 << endl; } else if (c == 2 && i >= 11) { cout << 2 << endl; } else if (c == 5 && i >= 11) { cout << 5 << endl; } else cout << 0 << endl; return 0; }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.util.*; import java.io.*; public class Solution { public static PrintWriter w = new PrintWriter(System.out); public static void main(String args[] ) throws Exception { Reader in = new Reader(); int n = in.nextInt(); char[] arr = in.next().toCharArray(); int cnt = 0; for (char c : arr) { if(c == '8') cnt++; } //w.println(cnt); int ans = 0; if(n < 11 || cnt == 0) ans = 0; else { int rem = n - cnt; ans = 0; int x = Math.min(cnt,rem/10); ans += x; cnt -= x; rem -= (rem/10)*10; if(cnt != 0) { ans += (cnt+rem)/11; } } w.println(ans); w.flush(); return; } } class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String nextLine() throws IOException { int c = read(); while(isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while(!isEndOfLine(c)); return res.toString(); } public String next() throws IOException { int c = read(); while(isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while(!isSpaceChar(c)); return res.toString(); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while(c <= ' ') c = read(); boolean neg = (c == '-'); if(neg) c = read(); do { ret = ret * 10 + c - '0'; } while((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public int[] nextIntArray(int n) throws IOException { int a[] = new int[n]; for(int i = 0; i < n; i++) a[i] = nextInt(); return a; } public int[][] next2dIntArray(int n, int m) throws IOException { int a[][] = new int[n][m]; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] = nextInt(); return a; } public char nextChar() throws IOException { return next().charAt(0); } public long nextLong() throws IOException { long ret = 0; byte c = read(); while(c <= ' ') c = read(); boolean neg = (c == '-'); if(neg) c = read(); do { ret = ret * 10 + c - '0'; } while((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while(c <= ' ') c = read(); boolean neg = (c == '-'); if(neg) c = read(); do { ret = ret * 10 + c - '0'; } while((c = read()) >= '0' && c <= '9'); if (c == '.') { while((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if(neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if(bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if(bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if(din == null) return; din.close(); } public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
q = int(input()) w= list(input()) e = w.count('8') r = q//11 t = min(e, r) print(t)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) m = input() f = m.count('8',0,len(m)) if 11*f < n: print(f) else: print(n // 11)
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.math.*; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.List.*; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub // ApplicationContext con = new // ClassPathXmlApplicationContext("bean.xml"); FastReader in = new FastReader(); StringBuilder out = new StringBuilder(); int n = in.nextInt(); String str = in.next(); if (!str.contains("8") || str.length() < 11) { System.out.println(0); return; } ArrayList<Character> arr = new ArrayList<>(); for (int i = 0; i < str.length(); i++) { arr.add(str.charAt(i)); } Collections.sort(arr); int s = arr.indexOf('8'); int e = arr.lastIndexOf('8'); int m = e - s + 1; System.out.println(Math.min(n / 11, m)); } } class Node { int data; Node left, right; Node(int d) { data = d; left = right = null; } } class BinaryTree { static Node head; Node root; /* * Given a binary search tree and a number, inserts a new node with the * given number in the correct place in the tree. Returns the new root * pointer which the caller should then use (the standard trick to avoid * using reference parameters). */ Node insert(Node node, int data) { /* * 1. If the tree is empty, return a new, single node */ if (node == null) { return (new Node(data)); } else { /* 2. Otherwise, recur down the tree */ if (data <= node.data) { node.left = insert(node.left, data); } else { node.right = insert(node.right, data); } /* return the (unchanged) node pointer */ return node; } } /* * Given a non-empty binary search tree, return the minimum data value found * in that tree. Note that the entire tree does not need to be searched. */ int minValue(Node node) { Node current = node; /* loop down to find the leftmost leaf */ while (current.left != null) { current = current.left; } return (current.data); } public int maxValue(Node node) { Node cur = node.right; while (cur.right != null) { cur = cur.right; } return cur.data; } boolean isBST() { return isBSTUtil(root, Integer.MIN_VALUE, Integer.MAX_VALUE); } public boolean isBSTUtil(Node node, int min, int max) { if (node == null) { return true; } if (node.data < min || node.data > max) { return false; } return (isBSTUtil(node.left, min, node.data - 1) && isBSTUtil(node.right, node.data + 1, max)); } } class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
#JMD #Nagendra Jha-4096 import sys import math #import fractions #import numpy ###File Operations### fileoperation=0 if(fileoperation): orig_stdout = sys.stdout orig_stdin = sys.stdin inputfile = open('W:/Competitive Programming/input.txt', 'r') outputfile = open('W:/Competitive Programming/output.txt', 'w') sys.stdin = inputfile sys.stdout = outputfile ###Defines...### mod=1000000007 ###FUF's...### def nospace(l): ans=''.join(str(i) for i in l) return ans ##### Main #### t=1 for tt in range(t): n=int(input()) s=str(input()) c=s.count('8') ans=0 for i in range(c): n-=11 if n<0: break ans+=1 print(ans) #n,k,s= map(int, sys.stdin.readline().split(' ')) #a=list(map(int,sys.stdin.readline().split(' '))) #####File Operations##### if(fileoperation): sys.stdout = orig_stdout sys.stdin = orig_stdin inputfile.close() outputfile.close()
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n=int(input()) string=input() a=string.count('8') if(a>(n//11)): a=n//11 print(min(a,(n-a)//10))
1060_A. Phone Numbers
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n" ], "output": [ "2\n", "1\n", "0\n" ] }
{ "input": [ "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n" ], "output": [ "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n" ] }
CORRECT
python3
n = int(input()) s = list(map(int, list(input()))) e = s.count(8) y = n - e if e <= y // 10: print(e) elif e == 0: print(0) else: u = 0 for i in range(0, e): a = e - i x = y + i if a >= x // 10: if x > u: u = x // 10 else: if a > u: u = a print(u)