24 12 12 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Right Answer is 6 You can solve this problem quickly by using the multiset and set data structures. To find the answer, use the set iterator. My solution is similar: map x to x - 600 and use array to count its frequency. Then accumulate all the freq[x] / 4 and just print the sum. As the diameter is constrained in [600,700], there will be at most 101 different values. "Some tram drivers are fans of fast driving, and they damage both rails and their trams. If a tram accelerates to a high speed, say 80 kilometers per hour, and then brakes sharply before a stop, it goes some distance skidding." Is this "initial D" reference?! Edited by author 19.08.2018 20:53 Edited by author 12.03.2016 20:21 n = int(input()) a = [] summ = 0 for i in range(n): a.append(int(input())) b = list(set(a)) for i in range(len(b)): c=a.count(b[i]) if c > 3: summ+=c//4 print(summ) var A:array[1..1000] of integer; i,s,n,b,r,m,j,k,d,q:integer; begin s:=0; r:=0; q:=0; read(n); for i:=1 to n do readln(A[i]); begin for i := 1 to n-1 do for j := 1 to n-i do if A[j] > A[j+1] then begin k := A[j]; A[j] := A[j+1]; A[j+1] := k end; end; for i:=1 to (n-1) do begin d:=i+q; if (A[d]=A[d+1]) then s:=s+1 else s:=0; if s=3 then begin r:=r+1; s:=0; q:=1+q; end; end; write(r); end. [code deleted] Edited by moderator 19.11.2019 22:49 [code deleted] Edited by moderator 19.11.2019 22:50 [code deleted] Edited by author 07.10.2014 17:38 Edited by moderator 19.11.2019 22:50 [code deleted] Edited by moderator 19.11.2019 22:50 #include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } 5 600 600 600 600 600 Thank you!!! #include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } look at my test .... use your program 10 600 600 600 600 600 600 600 600 600 600 I think your answer is 7... But true answer is 2! Edited by author 26.05.2013 09:50 Sorry, but true answer is 1, on my opinion Edited by author 04.12.2014 17:01 Edited by author 04.12.2014 17:02 5 600 600 600 600 600 what is the answer for this test? my programm writes 1 isn't it right?? import java.util.ArrayList; import java.util.Scanner; public class _1617 { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); ArrayList<Integer> list = new ArrayList<Integer>(); int n, i, count1 = 0, count2 = 0; n = s.nextInt(); int[] res = new int[n]; for (i = 0; i < n; i++) { res[i] = s.nextInt(); list.add(res[i]); } int e = 0; for (i = 0; i < list.size(); i++) { if (list.get(e).equals(res[i])) { count1++; if (count1 == 4) { count2++; } } } System.out.println(count2); } } all the tires are of the same size and not different telling coz got an ac Edited by author 18.02.2012 07:18 And there are can be more than 4 tires the same size. Good luck! here is my code #include<stdio.h> #include<stdlib.h> int main() {
int n,a[150],i,j,c[150]={0},s=0,r;
scanf("%d",&n);
for(i=0;i<n;i++) {
scanf("%d",&a[i]);
}
for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(a[i]==a[j]) { c[i]++; } } }
for(i=0;i<n;i++) { r=c[i]/4; s=s+r; }
if(n==c[0]) { printf("%d\n",c[0]/4); } else { printf("%d\n",s); }
return 0;
} #include <stdio.h> int main(){ int i,n,j,m[151],d; scanf("%d",&n); for(i=0;i<n;++i) scanf("%d",&m[i]); for(i=0;i<n;++i) for(j=0;j<n;++j) if(m[i]<m[j]){ d=m[i]; m[i]=m[j]; m[j]=d; } d=0; for(i=0;i<n-3;++i) if(m[i]==m[i+1]) if(m[i+1]==m[i+2]) if(m[i+2]==m[i+3]) if(m[i+3]>=600) if(m[i+3]<=700){ ++d; i=i+4; }
printf("%d",d); return 0; } This is my source: var arn:array[1..150]of integer; i,j,n,ans,t:integer; begin t:=1;ans:=0; readln(n); for i:=1 to n do readln(arn[i]); for i:=1 to n do if arn[i]<>0 then begin for j:=1 to n do begin if (i<>j) and (arn[i]=arn[j]) then begin t:=t+1; arn[j]:=0 end; if t=4 then begin t:=1; ans:=ans+1; end; end; t:=1; end; writeln(ans); end. Can anybody tell me, where mystake? I think to my programm is right. What is input in test 4?Help, please. Can somebody help me? I've got WA on the test №3. I've got no idea what's wrong. Please, help me. public void solve()throws Exception{ int n = nextInt(); int [] a = new int[101]; int c =0,b; for (int i=0;i<n;i++){ b = nextInt(); a[b-600]++; } for (int i=0;i<101;i++){ c+=a[i]>>1; } out.println(c>>2); } The description says 4 pairs. That means 8 wheels. I got WA when I used that definition. import java.util.Arrays; import java.util.Scanner; public class Example2 { private static int[] col; private static int count = 1; private static int superCount = 0; public static void main(String[] args) { try { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); if (a>=0 && a<=150){ col = new int[a]; for (int i = 0; i < a; i++) { col[i]=scanner.nextInt(); if(col[i]<600 || col[i]>700){ //System.out.print("0"); throw new Exception(); } } Arrays.sort(col); for (int i = 1; i < col.length; i++) { if (col[i]==col[i-1]) { count ++; if (count==4) { superCount ++; count=1; } }else count=1; } System.out.print(superCount); }else if (a>=0){System.out.print("0");} } catch (Exception e) {} } } why the wrong answer? please tell me test № 5. sorry for bad english. Edited by author 09.11.2010 02:45 #include <iostream> #include <algorithm> using namespace std; int main() { int mass[160]={0}; int n,i,kolvo=0,xz=1; cin>>n; for (i = 0; i < n; i++) { cin>>mass[i]; } sort(&mass[0],&mass[n]); for (i = 1; i < n; i++) { if (mass[i]==mass[i-1]) { xz++; } if (mass[i]!=mass[i+1]) { if (xz/4>=1) { kolvo+=xz/4.0; xz=1; } } } cout<<kolvo; return 0; } You can use not only the wheels of the same size help me!!! What is 4th test? I got Ac help me!!! What is 4th test? |
|