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
java
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n = s.nextInt(); String a = s.next(); int p=0; for(int i=0;i<n;i++) { if(a.charAt(i)=='8') p++; } n=n/11; System.out.println(Math.min(n,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
cpp
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long INF = 1000000000; template <class T> T read(T &x) { char c; int flag = 1; while ((c = getchar()) < '0' || c > '9') if (c == '-') flag *= -1; x = c - '0'; while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0'; x *= flag; return x; } int freq[10]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) { char x; cin >> x; freq[x - 48]++; } cout << min(n / 11, freq[8]) << endl; }
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 day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; struct edge { int to, cost; }; bool isupper(char c) { if ('A' <= c && c <= 'Z') return 1; return 0; } bool islower(char c) { if ('a' <= c && c <= 'z') return 1; return 0; } bool isPrime(int x) { if (x == 1) return 0; if (x == 2) return 1; if (x % 2 == 0) return 0; for (int i = 3; i * i <= x; i++) if (x % i == 0) return 0; return 1; } bool iskaibun(string s) { for (int i = 0; i < s.size() / 2; i++) if (s[i] != s[s.size() - i - 1]) return 0; return 1; } bool isnumber(char c) { return ('0' <= c && c <= '9'); } bool isalpha(char c) { return (isupper(c) || islower(c)); } void printvi(vector<int> v) { for (int i = (int)0; i < (int)v.size(); i++) { if (i) cout << " "; cout << v[i]; } cout << endl; } void printvil(vector<int> v) { for (int i = (int)0; i < (int)v.size(); i++) { cout << v[i] << endl; } } void printvvi(vector<vector<int>> v) { for (int i = (int)0; i < (int)v.size(); i++) { for (int j = (int)0; j < (int)v[i].size(); j++) { if (j) cout << " "; cout << v[i][j]; } cout << endl; } } void printvstr(vector<string> v) { for (int i = (int)0; i < (int)v.size(); i++) { cout << v[i] << endl; } } int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } struct S { int idx, value; }; signed main() { int n; cin >> n; string s; cin >> s; int v[20] = {0}; for (int i = (int)0; i < (int)n; i++) { v[s[i] - '0']++; } int ans = v[8]; int anss = 0; for (int i = (int)1; i < (int)ans + 1; i++) { if ((n - i) / 10 >= i) anss = i; } cout << anss << endl; }
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()) p=input() a=[] for i in range(n): a.append(int(p[i])) x=a.count(8) y=(len(a))//11 print(min(x,y))
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() x = raw_input() d = dict() k = 0 for i in x: if (i == '8'): k+=1 print(min(n//11, k))
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() s = input() n = int(n) inp = [] length = len(s) for i in range(0, length): inp.append(int(s[i])) count = inp.count(8) from math import * total = floor(length/11) if total < count: print(total, end='') else: print(count, end='')
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 cnt = 0; for (int i = 0; s[i]; i++) { if (s[i] == '8') cnt++; } cout << min(cnt, (int)s.size() / 11) << endl; }
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() a=s.count('8') print(min(a,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
cpp
#include <bits/stdc++.h> using namespace std; int main() { char s[101]; int n, i, sum8 = 0, sum = 0, total = 0; cin >> n; cin >> s; for (i = 0; i < n; i++) { if (s[i] == '8') sum8++; sum++; } if (sum8 >= sum / 11) total = sum / 11; else total = sum8; cout << total << 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
n = int(input()) phone = input() count = 0 for i in range(n): if (phone[i] == '8'): count += 1 print(int(min(count, 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() a=s.count('8') b=int(n/11) print(min(a,b))
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
while True: try: n = int(input()) a = input() b = a.count('8') ans = min(b,n//11) print(int(ans)) except: 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
java
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class DB { public static void main(String args[]) { Scanner sc=new Scanner(System.in); long n=sc.nextLong(); String s=sc.next(); long ans=0; for(int i=0;i<s.length();i++) { char ch=s.charAt(i); if(ch=='8') ans++; } ans=Math.min(ans,(n/11)); System.out.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()) str = input() print(min(str.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
cpp
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int MAX = 100005; long long modexp(long long x, long long n) { if (n == 0) return 1LL; if (n % 2 == 0) { long long y = modexp(x, n / 2) % mod; return (y * y) % mod; } return (x * modexp(x, n - 1) % mod) % mod; } long long powr(long long x, long long n) { long long ans = 1; for (int i = 1; i <= n; i++) ans = ans * x; return ans; } int main() { int n; scanf("%d", &n); string s; cin >> s; int f[10] = {0}; for (int i = 0; i < n; i++) { f[s[i] - '0']++; } int ans = 0; while (f[8]) { int len = 1; f[8]--; for (int i = 0; i < 10; i++) { if (i == 8 || f[i] == 0) continue; if (f[i] < (11 - len)) { len += f[i]; f[i] = 0; } else { f[i] -= (11 - len); len = 11; break; } } if (len == 11) ans++; else if (f[8] >= (11 - len)) { f[8] -= (11 - len); ans++; } else break; } printf("%d\n", 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=input() m=list(int(x) for x in raw_input()) if len(m)<11: print 0 else: if 8 in m: if m.count(8)>=len(m)//11: print len(m)//11 else: print m.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
n=int(input()) a=str(input()) a1=n//11 s=a.count("8") print(min(a1,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
cpp
#include <bits/stdc++.h> inline int min(int x, int y) { return x < y ? x : y; } inline int getch() { int ch = getchar(); while (!isdigit(ch)) ch = getchar(); return ch; } int n; int main() { scanf("%d", &n); int NOE = 0; for (register int i = 1; i <= n; ++i) { int ch = getch(); if (ch == '8') ++NOE; } printf("%d\n", min(NOE, 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; int32_t main() { long long m; long long n, k = 0, k1 = 0, k0 = 0, sm = 0, mn = 1e5, sm_original = 0, f = 0, k2 = 0, t, mx = -1; string s; cin >> n; cin >> s; for (long long i = 0; i < s.size(); i++) if (s[i] == '8') k++; n = s.size() / 11; cout << min(n, k); }
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()) li = list(raw_input()) print min(li.count('8'),len(li)/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
n=int (raw_input()) s=raw_input() c=s.count("8") t=n/11 if t<=c: print t elif c<t: print c 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
java
import java.math.*; import java.util.Scanner; import static java.lang.Math.min; public class ex12 { public static void main(String[]args){ Scanner in = new Scanner(System.in); int b = in.nextInt(); BigInteger x = in.nextBigInteger(); int[] a = new int[b]; for(int i = 0; i < b; i++){ BigInteger q = x.mod(BigInteger.valueOf(10)); a[i] = q.intValue(); x = x.divide(BigInteger.valueOf(10)); } int z = 0; for (int i = 0; i < a.length; i++){ if (a[i] == 8) { z++; } } if (b / 11 == z) System.out.println(z); else System.out.println(min(z, b / 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int an = 0; char a[100]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == '8') { an++; } } int m = n / 11; cout << min(m, an); }
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() ct8=0 for i in range(n): if s[i]=='8': ct8+=1 print min(ct8,n/11) exit()
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; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1)); long long get_random_int(long long a, long long b) { return uniform_int_distribution<long long>(a, b)(rng); } int main() { ios_base::sync_with_stdio(false); cout << fixed; cout.precision(10); int n; cin >> n; string s; cin >> s; int cnt8 = 0; int cntr = 0; for (int i = 0; i < n; ++i) { if (s[i] == '8') { cnt8++; } else { cntr++; } } int res = 0; for (int i = cnt8; i >= 0; --i) { res = max(res, min(i, cntr / 10)); cntr++; } cout << res; 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; long long n; string s; long long cnt[10]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; cin >> s; for (long long(i) = (0); (i) <= (n - 1); (i)++) cnt[s[i] - '0']++; cout << min(n / 11, cnt[8]) << 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.*; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = sc.nextLine(); int count = 0; str = sc.nextLine(); for(int i = 0; i < n; i++) { if(str.charAt(i) == '8') { count++; } } int div = n / 11; if(count < div) { System.out.println(count); } else { System.out.println(div); } } }
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, nph = s.count('8'), n//11 print(min(c,nph))
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() num_eight=0 for i in range(n): if s[i]=='8': num_eight+=1 phone_num=n//11 if num_eight<=phone_num: print(num_eight) else: print(phone_num)
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
long = int(input()) ch = input() nb = 0 for i in range(0, long): if ch[i] == '8': nb += 1 div=long//11 if long>=11: print(min(div,nb)) 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
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int count=0; sc.nextLine(); String s=sc.nextLine(); for(int i=0;i<s.length();i++) { if(s.charAt(i)=='8') count++; } if(count>=n/11){System.out.println(n/11);} 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
java
import java.io.*; import java.util.*; public class cons { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n=sc.nextInt(); String h=sc.nextLine(); int c=0; for(int i=0;i<n;i++) { if(h.charAt(i)=='8') c++; } int ans=0; int l=n; for(int i=0;i<c && l>=11;i++) { ans++; l=l-11; } out.print(ans); out.flush(); } static class pair{ int l; int r; pair(int l,int r){ this.l=l; this.r=r; } public String toString() { return l+" "+r; } } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream system) { br = new BufferedReader(new InputStreamReader(system)); } public Scanner(String file) throws Exception { br = new BufferedReader(new FileReader(file)); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public String nextLine() throws IOException { return br.readLine(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public char nextChar() throws IOException { return next().charAt(0); } public Long nextLong() throws IOException { return Long.parseLong(next()); } public boolean ready() throws IOException { return br.ready(); } public void waitForInput() throws InterruptedException { Thread.sleep(3000); } } }
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") n if m == 0 or n < 11: print(0) else: lo,hi = 1,m while lo <= hi: mid = (lo+hi) // 2 if mid * 10 <= n - mid: lo = mid + 1 else: hi = mid - 1 print(hi)
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
# coding=utf-8 n=int(raw_input()) s=raw_input() k=0 if len(s)>=11 and '8' in s: if s.count('8')>=len(s)/11: k=k+len(s)/11 else: k=k+s.count('8') print k
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=s.count('8') print(min(eight,int(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
x=int(input()) s=input() d=x//11 e=s.count('8') print(min(e,d))
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; char str[1000]; int main() { while (cin >> n) { cin >> str; ans = 0; for (int i = 0; i < n; ++i) if (str[i] == '8') ans++; ans = min(ans, n / 11); cout << ans << 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
n=int(input()) s=input() k=s.count('8') if(n//11<=k): print(n//11) else: print(k)
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, num, ans, cnt = 0; char x; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; if (x == '8') num++; } for (int i = 1; i <= num; i++) { for (int j = 1; j <= 11; j++) cnt++; if (cnt > n) { ans = i - 1; break; } if (cnt == n) { ans = i; break; } } if (cnt < n) ans = num; cout << 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
python3
n = int(input()) s = input() if n >= 11: print(min(s.count('8'), n // 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
java
import java.util.Scanner; public class PhoneNumbers { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; String ch=""; do{ //System.out.println("n = "); n = sc.nextInt(); }while ((n<1)||(n>100)); do{ //System.out.println("ch = "); ch = sc.next(); }while ((ch.length()!=n)||(ch.indexOf(" ")!=-1)||(!ch.matches("[0-9]+"))); if(ch.indexOf("8")==-1){ System.out.println(0); }else{ int numberOf8 = ch.length() - ch.replace("8", "").length(); if (numberOf8 <= ch.length() / 11){ System.out.println(numberOf8); } else{ System.out.println(ch.length() / 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() t = 0 for i in range (len(m)): if (m[i]=='8'): t=t+1 if (n//11<=t): print (n//11) print () else: print (t) print ()
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.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN void solve(int TC) throws Exception{ int n = ni(), c= 0; String s = n(); for(int i = 0; i< n; i++)if(s.charAt(i)=='8')c++; pn(Math.min(c, n/11)); } //SOLUTION ENDS long mod = (int)1e9+7, IINF = (long)1e17; final int MAX = (int)1e5+1, INF = (int)1e9, root = 3; DecimalFormat df = new DecimalFormat("0.00000000000"); double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8; static boolean multipleTC = false, memory = true; FastReader in;PrintWriter out; void run() throws Exception{ in = new FastReader(); out = new PrintWriter(System.out); int T = (multipleTC)?ni():1; //Solution Credits: Taranpreet Singh for(int i = 1; i<= T; i++)solve(i); out.flush(); out.close(); } public static void main(String[] args) throws Exception{ if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start(); else new Main().run(); } long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);} int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);} int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));} void p(Object o){out.print(o);} void pn(Object o){out.println(o);} void pni(Object o){out.println(o);out.flush();} String n(){return in.next();} String nln(){return in.nextLine();} int ni(){return Integer.parseInt(in.next());} long nl(){return Long.parseLong(in.next());} double nd(){return Double.parseDouble(in.next());} class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String s) throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while (st == null || !st.hasMoreElements()){ try{ st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } return st.nextToken(); } 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
java
import java.util.*; import java.io.*; public class Param { public static void main( String[]args) { Scanner param=new Scanner(System.in); int size=param.nextInt(); param.nextLine(); String a =param.next(); char []arr=new char [size]; for(int i=0;i<size;i++){ arr[i]=a.charAt(i); } int count=0; for(int i=0;i<arr.length;i++){ if(arr[i]=='8'){ count++; } } if(size/11<=count){ System.out.println((size/11)); } else if(count<=size/11){ System.out.println(count); } 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
java
import java.util.Scanner; public class A { public static void main(String[] ar) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); char[] digits = sc.nextLine().toCharArray(); int n8 = 0; for (char digit : digits) { if (digit == '8') n8++; } System.out.println(Math.min(n8, 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.ArrayList; import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = sc.next(); int eightNums = 0; int m = n/11; for(int i = 0; i<str.length() && eightNums < m; i++) { if(str.charAt(i) == '8') { eightNums++; } } System.out.println(eightNums); } }
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 counter(cards, n): if(n<11): return 0 else: max_by_len = n // 11 count_of_eight = 0 for c in cards: if c == '8': count_of_eight += 1 if count_of_eight >= max_by_len: break return count_of_eight def stand_input(): n = int(input()) cards = input() res = counter(cards, n) print(res) stand_input()
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()) c=0 x=input() for i in range(len(x)): if x[i]=='8': c+=1 if c==0: #print (0) print(0) else: a=[n//11,c] print(min(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 in = new Scanner(System.in); int n = in.nextInt(), cnt = 0, ans = n / 11; String s = in.next(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '8') { cnt++; } } System.out.println(Math.min(ans, cnt)); } }
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 n=int(input()) s=input() c=0 d=s.count('8') print(min(n//11,d))
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=str(input()) l=list(s) k=l.count('8') m=min(int(a/11),k) print(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
a=input() b=input() cont=0 i=0 while(i<int(a) and cont<=int(a)//11-1): if b[i]=="8": cont=cont+1 i=i+1 print(cont)
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, count = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '8') count++; } if (n < 11) cout << "0" << endl; else { cout << min(count, 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
import collections def solve(): n = int(input()) cards = collections.Counter(input()) eights = cards['8'] ans: int = min(eights, n // 11) print(ans) 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
cpp
#include <bits/stdc++.h> using namespace std; int n, con; char a[100000]; int main() { scanf("%d", &n); scanf("%s", a); for (int i = 0; i < n; ++i) if (a[i] == '8') con++; printf("%d\n", min(con, 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; signed main() { int n, cnt = 0; char s[105]; cin >> n; scanf("%s", s); for (int i = 0; i < n; i++) cnt += s[i] == '8'; cout << 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
python3
n=int(input()) number=str(input()) ndiv=int(n/11) if(n<11): print('0') else: nume=number.count("8") if nume>=ndiv: print(ndiv) else : print(nume)
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> #pragma GCC optimize(2) using namespace std; const int inf = 0x3f3f3f3f; string s; int len; int fac[101]; inline char nc() { static char buf[100000], *p1 = buf, *p2 = buf; if (p1 == p2) { p2 = (p1 = buf) + fread(buf, 1, 100000, stdin); if (p1 == p2) return EOF; } return *p1++; } inline void read(int &x) { char c = getchar(); int b = 1; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') b = -1; for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar()) ; x = x * b; } inline void read(long long &x) { char c = getchar(); int b = 1; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') b = -1; for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar()) ; x = x * b; } int main(int argc, char *argv[]) { int flag = 0, sum = 0; read(len); cin >> s; for (int i = (0); i <= (len - 1); i++) { if (s[i] == '8') flag = 1, sum++; } if (!flag || len <= 10) { printf("0\n"); return 0; } for (int i = (sum); i >= (1); i--) if (i + i * 10 <= len) { printf("%d\n", i); return 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
python3
n = int(input()) s = input() n8 = 0 for x in s: if x == '8': n8 += 1 print(min(n8, 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()) lst = list(input()) print(min(lst.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()) num = int(input()) p = 0 count = 0 c = 0 a=[0] while n != 0: if (num % 10) == 8: p += 1 c-=1 num //= 10 c += 1 n-=1 #print(c,p) while c >= 10 and p > 0: c -= 10 p -= 1 count += 1 #print(c,p) if p>0: count=count+(c+p)//11 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; int main() { int n; cin >> n; int coun = 0; string s; cin >> s; for (int i = 0; i < n; i += 1) { if (s[i] == '8') coun++; } cout << min(coun, 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
java
import java.util.Scanner; public class Phone { public static void main(String[] args) { Scanner scanner = new Scanner (System.in); int n = scanner.nextInt(); String s = scanner.next(); int d=0; for (int i=0;i<n;i++) { if (s.charAt(i)=='8') d++; } int x = n/11; System.out.println(Math.min(x, d)); scanner.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()) s=list(str(input())) e,m=0,0 if '8' not in s or n<11: print(0) else: e=s.count('8') m=n//11 print(min(e,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()) s = input() eights = s.count('8') print(min(eights, len(s) // 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author ky112233 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); APhoneNumbers solver = new APhoneNumbers(); solver.solve(1, in, out); out.close(); } static class APhoneNumbers { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); String str = in.next(); int cnt = 0; for (int i = 0; i < n; i++) { if (str.charAt(i) == '8') cnt++; } int cnt2 = n / 11; out.println(Math.min(cnt, cnt2)); } } }
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; cin >> n; string s; cin >> s; int count = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '8') { count++; } } if (n == 11 && count >= 1) { cout << 1 << "\n"; } else { int a = n / 11; if (count >= a) { cout << a << "\n"; } else { cout << count << "\n"; } } 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() c=0 for i in range(len(s)): if(s[i]=='8'): c=c+1 a=n//11 print(min(c,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
# A. Phone Numbers n=int(input()) s=input() m=s.count("8") ans=min(m,n//11) 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
from collections import Counter n = int(input()) c = Counter(input()) if '8' in list(c): print(min(n//11,c['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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0; char st[100]; cin >> n; cin >> st; if (n >= 11) { for (int i = 0; i <= n; i++) { if (st[i] == '8') count++; else continue; } if (count == 0) { count = 0; } else if (count != 0 && n / count >= 11) { count = count; } else { count = n / 11; } } cout << 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; template <typename T> void read(T& x) { x = 0; T f = 1; char ch = getchar(); while (!isdigit(ch)) f = ch == '-' ? -f : f, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x *= f; } template <typename T> void viet(T x) { if (x > 9) viet(x / 10); putchar(x % 10 + '0'); } int n, cnt, ret; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '8') cnt++; } n -= cnt; int foo = min(cnt, n / 10); ret += foo; cnt -= foo; n -= foo * 10; if (cnt > 0) ret += (cnt + n) / 11; cout << ret << endl; }
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; const long long MAXN = 1123456; template <typename T> T sqr(T x) { return x * x; } template <typename T> void vout(T s) { cout << s << "\n"; exit(0); } long long bp(long long a, long long n) { long long res = 1; while (n) { if (n % 2) res *= a; a *= a; n >>= 1; } return res; } long long f(long long x) { long long res = 0; while (x) { res += x % 10; x /= 10; } return res; } long long a[MAXN]; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); long long n, kol = 0; cin >> n; for (int i = 0; i < n; i++) { char cc; cin >> cc; if (cc == '8') kol++; } cout << min(kol, n / 11) << "\n"; cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << "\n"; 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() n8 = 0 for i in range(n): if s[i] == '8': n8 += 1 ans = 0 for i in range(n8, 0, -1): if (n - i) // 10 >= i: ans = i break 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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; int phone_numbers = 0; int eights = 0; cin >> n; string cards; cin >> cards; for (int i = 0; i < n; i++) { if (cards[i] == '8') eights++; } cout << eights << endl; for (int i = 0; i < eights; i++) { if (n - 11 >= 0) phone_numbers++; } cout << phone_numbers; 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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, a, x = 0, y = 0; cin >> n; cin >> a; x = n / 11; while (a > 0) { if (a / 10 == 8) { y++; } a = a / 10; } if (y >= x) { cout << x; } else { cout << y; } }
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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, s8 = 0, sr, k; cin >> n; string s; cin >> s; for (i = 0; i < n; i++) if (s[i] == '8') s8 = s8 + 1; sr = n - s8; int a = sr / 10; if (s8 > a) { k = a; s8 = s8 - a; sr = sr - a * 10; if (sr + s8 - 1 >= 10) { s8 = s8 - 1 - (10 - sr); k = k + 1; int c = s8 / 10; k = k + c; } } else k = s8; cout << k; }
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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int length(long long int a) { int l = 0; while (a > 0) { l++; a = a / 10; } return l; } int main() { long long int n; cin >> n; long long int a = n / 2; int la = length(a); int ln = length(n); long int b, c; b = a / (pow(10, la - 1)); b = b * (pow(10, la - 1)); for (int i = la - 2; i >= 0; i--) { b = b + 9 * (pow(10, i)); } c = n - b; int sum = 0, t; while (b > 0) { t = b % 10; sum = sum + t; b = b / 10; } while (c > 0) { t = c % 10; sum = sum + t; c = c / 10; } cout << sum; }
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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const long long INF = 2e18; const long long N = 1e6 + 1; const long long mod = 1e9 + 1; const long double eps = 1E-7; using namespace std; void solve() { int n; string s; cin >> n; cin >> s; sort(s.begin(), s.end()); int x = 0; for (int i = n - 1; i >= 0; --i) { if (s[i] == '8') x++; if (x * 11 >= n) break; } cout << x << endl; } bool mtest = false; int main() { ios_base::sync_with_stdio(0); int TE = 1; if (mtest) cin >> TE; while (TE--) 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" ] }
IN-CORRECT
java
import java.util.*; public class phoneNumber { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); s.nextLine(); String s1=s.nextLine(); int x=n/11;int c=0,z=0; char ch[]=s1.toCharArray(); for(int i=0;i<ch.length;i++) { if(ch[i]=='8') { z=1; c++; } } if(n%11==0 && z!=0) { if(c>=x) System.out.println(x); } 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" ] }
IN-CORRECT
java
//package olympiads; import java.util.Scanner; public class taskA_codeforces { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); String [] arr = in.next().split(""); int x = 0; for (int i = 0; i < arr.length; i ++) { if (arr[i].equals("8")) { x += 1; } } int k = n - x; int s = n - x; while (s * 10 > k) { s -= 1; } if (n - s * 10 - s >= 10 && s < x) { System.out.println(Math.min(s, x) + 1); }else { System.out.println(Math.min(s, x)); } in.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" ] }
IN-CORRECT
java
import java.util.Scanner; public class A1060 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sw=1; String x = sc.next(); if (x.contains("8")) { int a=cont(x,'8',n); while(sw==1) { if((a*8)>n) { a--; }else { System.out.println(a); sw=0; } } }else { System.out.println("0"); } } public static int cont(String x, char p,int n) { int c = 0; for (int i = 0; i < n; i++) { if (x.charAt(i) == p) { c++; } } return 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" ] }
IN-CORRECT
java
import java.util.Scanner; public class ReadFile { public static int numberOfEight(String s){ int numberOfEight = 0; for(int i = 0 ; i<s.length() ; i++){ if(s.charAt(i) == '8'){ numberOfEight++; } } return numberOfEight; } public static void main(String[] args) { Scanner input = new Scanner(System.in); int length = input.nextInt(); String line = input.nextLine(); int numberOfNumbers = length/11; if(length < 11 || !line.contains("8")){ System.out.println("0"); return; } int numberOfEight = numberOfEight(line); if(numberOfNumbers <= numberOfEight){ System.out.println(numberOfNumbers); } } }
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" ] }
IN-CORRECT
python3
N = int(input()) s = input() eights = s.count("8") m = (len(s) % 11) + 1 print(min(eights, 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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; int ans = 0, ans1 = 0; string s; cin >> n; cin >> s; if (s.size() <= 10) { cout << "0"; return 0; } for (int i = 0; i < n; i++) { if (n % 11 == 0) { if (s[i] == '8') { ans++; if (ans >= (n / 11)) { ans1 = n / 11; cout << ans1; break; } } } else { if (s[i] == '8') { ans++; if (ans >= (n / 11)) { ans1 = n / 11; cout << ans1; break; } } } } if (ans == 0) cout << 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" ] }
IN-CORRECT
python3
n=int(input()) s=input() y=s.count('8') if '8' in s and len(s)>=11: x=len(s)//11 if x<=y: print(x) 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" ] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); String str = sc.nextLine(); int k = 0; for (int i=0;i<n;i++) { if (str.charAt(i) == '8') { k++; } } System.out.println(Math.min(k, (n - k) / 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" ] }
IN-CORRECT
python3
u=int(input()) d=[] s=0 arr=list(map(int,input())) #print(arr) try: if len(arr)>=11 and 8 in arr: count=arr.count(8) #print(count) for u in range(count): if 8 in arr: s=s+1 arr[arr.index(8)]=-1 d.append(8) for i in range(0,10): if i in arr: d.append(i) arr[arr.index(i)]=-1 except: pass print(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" ] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import com.sun.media.sound.SoftTuning; public class Solution { static int n; static int[] arr = new int[10]; static String num; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(br.readLine()); num = br.readLine(); solve(); System.out.println(result); } static int result; private static void solve() { int count = n/11; int sum = 0; for(int i=0;i<n;i++) arr[num.charAt(i)-'0']++; for(int i=0;i<=9;i++) { if(i==8) { if(count!=0) { if(arr[8]>count) { sum += (arr[8]-count); arr[8] = count; } continue; } } sum += arr[i]; } while(arr[8]!=0) { arr[8]--; if(sum>=10) { sum-=10; result++; }else 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" ] }
IN-CORRECT
python3
n = int(input().strip()) s = input().strip() if '8' not in s or n<11: print(0) else: c=n//11 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" ] }
IN-CORRECT
java
import java.util.*; import java.io.*; import java.math.*; public class Phone { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} public String nextLine(){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 s(){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 long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} public double d() throws IOException {return Double.parseDouble(s()) ;} public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;} } public static void main(String args[]) { PrintWriter out= new PrintWriter(System.out); Reader sc=new Reader(); int n = sc.i(); String s = sc.s(); int count = 0; for(int i=0;i<n;++i) { if(s.charAt(i)=='8') count++; } int count1 = n-count; if(n<11 || count==0) out.println("0"); else { int ans = 0; while(count > 0 && count1 > 0) { count--; count1-=10; ans++; } if(count>=11) ans+=(count/11); out.println(ans); } out.flush(); } }
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" ] }
IN-CORRECT
python3
n = int(input()) s = list(map(int, input().split())) 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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const long long inf = 1e9 + 7; using namespace std; long long read() { long long 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 f * x; } int n, k; char s[100005]; int main() { n = read(); scanf("%s", s + 1); for (int i = 1; i <= n; i++) if (s[i] = -'8') k++; n -= k; if (k < n / 10) printf("%d\n", k); else printf("%d\n", (k + 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" ] }
IN-CORRECT
java
import java.util.ArrayList; import java.util.List; import java.util.Arrays; import java.util.Collections; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.BufferedReader; import java.util.LinkedList; import java.util.Locale; import java.util.Iterator; import java.util.Stack; import java.util.Set; import java.util.HashSet; import java.util.TreeSet; import java.util.Map; import java.util.HashMap; import java.util.TreeMap; import java.util.BitSet; import java.lang.StringBuilder; import java.util.Queue; import java.util.Objects; import java.util.PriorityQueue; public class UvaProblems { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); Locale.setDefault(new Locale("en", "US")); int n = Integer.parseInt(in.readLine()); String a = in.readLine(); int total8s = 0; for(int i = 0; i<a.length(); i++) { if(a.charAt(i) == '8') { total8s ++; } } int veces = n/11; if(total8s >= veces) { out.println(veces); } else if(total8s == 0) { out.println(0); } else { out.println(veces-total8s); } out.flush(); } }
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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; int x = 0; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '8') { x++; } } int y = n; int p = 0; while (x > 0 && y > 9) { if (y > 9) { y -= 11; x--; p++; } } cout << p; 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" ] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; char s[a]; cout << s[5]; int cnt = 0; for (int i = 0; i < a; i++) { cin >> s[i]; if (s[i] == '8') { cnt++; } } if (cnt >= 1 && a % 11 == 0) { cout << a / 11; } else { cout << 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" ] }
IN-CORRECT
java
//package MyPackage.kfjf; import java.util.*; public class ComplexButNotBoring14ffv { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); // Map <Integer,Integer> map=new HashMap <>(); int freq8 = 0; String s = scan.next(); for (int i = 0; i < n; i++) { if (s.charAt(i) == '8') freq8++; } n = n - freq8; if (freq8 != 0) { int count = 0; while (n >= 10 && freq8 > 0) { freq8--; n -= 10; count++; // System.out.println(freq8+" "+n+" "+count); } if (n < 10&&n!=0 && freq8 > 1 && (10 - n) <= (freq8 - 1)) { count++; freq8--; count+=freq8/11; System.out.println(count); System.exit(0); } count+=freq8/11; System.out.println(count); } 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" ] }
IN-CORRECT
python3
n=int(input()) l=list(input()) a=list() c=0 for i in range(n): a.append(int(l[i])) if(a[i]==8): c=c+1 if(n>11): if(c==0): print('0') else: if(n/11>=c): print(c) else: print(n//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" ] }
IN-CORRECT
python3
n=int(input()) str = input() ans = 0 noofate = str.count("0") while n>=11 and noofate>0: if n>=11 and noofate>0: n-=11 noofate-=1 ans+=1 else: break 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" ] }
IN-CORRECT
java
import java.util.Scanner; import java.math.BigInteger; public class PingLatin { public static void main(String[] args) { Scanner ler = new Scanner(System.in); BigInteger n = ler.nextBigInteger(); System.out.println(BigInteger.valueOf(5).modPow(n,BigInteger.valueOf(100))); } }