f1
stringlengths
6
6
f2
stringlengths
6
6
content_f1
stringlengths
66
8.69k
content_f2
stringlengths
48
42.7k
flag
int64
0
1
__index_level_0__
int64
0
1.19M
A12852
A11545
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package google.codejam; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Problem2 { public Problem2() { super(); } private static int convert(String input) { String[] inputArray = input.split(" "); int noOfCases = Integer.parseInt(inputArray[0]); int noOfSurpriseCasesPossible = Integer.parseInt(inputArray[1]); int p = Integer.parseInt(inputArray[2]); List<Integer> cases = new ArrayList<Integer>(); for(int i = 3;i<inputArray.length; i++) cases.add(Integer.parseInt(inputArray[i])); Collections.sort(cases, Collections.reverseOrder()); int minSurprisingSum = p*3 - 4; int minNonSurprisingSum = p*3 -2; int countNonSurprisingCases = 0; int countSurprisingCases = 0; for(int score:cases) { if(score<minSurprisingSum || score<=p) break; if(score>=minNonSurprisingSum) countNonSurprisingCases++; else if(score>=minSurprisingSum) countSurprisingCases++; } countNonSurprisingCases+=Math.min(countSurprisingCases, noOfSurpriseCasesPossible); //System.out.println(countNonSurprisingCases); return countNonSurprisingCases; } public static void main(String[] args) { try { BufferedReader reader = new BufferedReader(new FileReader("D:\\codejam\\2012\\B.in")); BufferedWriter writer = new BufferedWriter(new FileWriter("D:\\codejam\\2012\\B.out")); //... Loop as long as there are input lines. String line = null; reader.readLine(); int i=1; while ((line=reader.readLine()) != null) { writer.write("Case #"+i+": "+convert(line)); writer.newLine(); // Write system dependent end of line. i++; } //... Close reader and writer. reader.close(); // Close to unlock. writer.close(); // Close to unlock and flush to disk. } catch(Exception ex) { ex.printStackTrace(); } } }
0
0
A12852
A11781
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintStream; import java.util.Scanner; public class GooglerScores { public static void main(String args[]) throws FileNotFoundException { ////////////////////////////////////// // Begin Code Jam regular code // ////////////////////////////////////// Scanner inFile = new Scanner(new File("B-small-attempt0.in")); PrintStream outFile = new PrintStream(new File("B-small0-out.txt")); int numCases = inFile.nextInt(); inFile.nextLine(); // Gets rid of newline char ////////////////////////////////////// // End Code Jam regular code // ////////////////////////////////////// for(int i=1; i<=numCases; i++) { int numGooglers = inFile.nextInt(); int maxNumSurprising = inFile.nextInt(); int leastValid = inFile.nextInt(); int validGooglers = 0; int validSurprising = 0; for(int j=0; j<numGooglers; j++) { int nextTotal = inFile.nextInt(); int[] normalScore = calcNormalScore(nextTotal); int[] surprisingScore = calcSurprisingScore(nextTotal); if(hasValidScore(normalScore, leastValid)) { validGooglers++; } else if (hasValidScore(surprisingScore, leastValid) && validSurprising < maxNumSurprising) { validGooglers++; validSurprising++; } } printCase(outFile, i, validGooglers); } } private static void printCase(PrintStream outStream, int i, int n) { outStream.println("Case #" + i +": " + n); } private static int[] calcNormalScore(int totalScore) { int[] scores = new int[3]; if(totalScore % 3 == 0) { for(int i=0; i<3; i++) { scores[i] = totalScore/3; } } else if(totalScore % 3 == 1) { scores[0] = totalScore / 3; scores[1] = scores[0]; scores[2] = scores[0] + 1; } else if(totalScore % 3 == 2) { scores[0] = totalScore / 3; scores[1] = scores[0] + 1; scores[2] = scores[1]; } return scores; } private static int[] calcSurprisingScore(int totalScore) { int[] scores = new int[3]; if (totalScore % 3 == 1 || totalScore <= 0) { // There is no such surprising score for (int i = 0; i < 3; i++) scores[i] = 0; } else if (totalScore % 3 == 0) { scores[0] = totalScore / 3 - 1; scores[1] = totalScore / 3; scores[2] = totalScore / 3 + 1; } else if (totalScore % 3 == 2) { scores[0] = totalScore / 3; scores[1] = scores[0]; scores[2] = scores[0] + 2; } return scores; } private static boolean hasValidScore(int[] scores, int leastValid) { for(int i=0; i<scores.length; i++) { if(scores[i] >= leastValid) return true; } return false; } }
0
1
A12852
A12785
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.InputStreamReader; import org.junit.Assert; public class DancingWithTheGooglers { public static void main( final String[] args ) throws Exception { final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) ); final int T = Integer.parseInt( br.readLine() ); for ( int ii = 0; ii < T; ++ii ) { final String[] parts = br.readLine().split( " " ); final int N = Integer.parseInt( parts[ 0 ] ); final int S = Integer.parseInt( parts[ 1 ] ); final int p = Integer.parseInt( parts[ 2 ] ); final int[] t = new int[N]; for ( int i = 0; i < N; ++i ) { t[ i ] = Integer.parseInt( parts[ i + 3 ] ); } System.out.printf( "Case #%d: %d\n", ii + 1, solve( N, S, p, t ) ); } } private static int solve( final int n, int s, final int p, final int[] t ) { int cnt = 0; for ( int i = 0; i < t.length; ++i ) { final int k = t[ i ] / 3; final int mod = t[ i ] % 3; if ( k + ( mod > 0 ? 1 : 0 ) >= p ) { ++cnt; } else if ( s > 0 ) { // k + k + k -> k+1 + k + k-1 if ( mod == 0 && k - 1 >= 0 && k + 1 >= p ) { ++cnt; --s; } // k+1 + k + k -> k+1 + k+1 + k-1 (not enough) || k+2 + k + k-1 (not ok) // k+1 + k+1 + k -> k+2 + k + k if ( mod == 2 && k + 2 >= p ) { ++cnt; --s; } } } return cnt; } @org.junit.Test public void statement1() { final int[] t = { 15, 13, 11 }; Assert.assertEquals( 3, solve( 3, 1, 5, t ) ); } @org.junit.Test public void statement2() { final int[] t = { 23, 22, 21 }; Assert.assertEquals( 2, solve( 3, 0, 8, t ) ); } @org.junit.Test public void statement3() { final int[] t = { 8, 0 }; Assert.assertEquals( 1, solve( 2, 1, 1, t ) ); } @org.junit.Test public void statement4() { final int[] t = { 29, 20, 8, 18, 18, 21 }; Assert.assertEquals( 3, solve( 6, 2, 8, t ) ); } }
0
2
A12852
A12003
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new FileReader(args[0])); FileWriter out = new FileWriter(args[1]); int T = Integer.parseInt(in.readLine()); for (int t = 1; t <= T; t++) { String data[] = in.readLine().split("\\ "); int N = Integer.parseInt(data[0]); int S = Integer.parseInt(data[1]); int p = Integer.parseInt(data[2]); int[] totalPoints = new int[N]; for (int i = 0; i < N; i++) totalPoints[i] = Integer.parseInt(data[i + 3]); int unconditionalSucc = 0; int failed = 0; int upperLimit; int lowerLimit; if (p >= 2) { upperLimit = 3 * p - 3; lowerLimit = 3 * p - 4; } else if (p == 1) { upperLimit = 0; lowerLimit = 1; } else { upperLimit = -1; lowerLimit = -1; } for (int i = 0; i < totalPoints.length; i++) { if (totalPoints[i] > upperLimit) unconditionalSucc++; else if (totalPoints[i] < lowerLimit) failed++; } int uncertain = N - failed - unconditionalSucc; out.write("Case #" + t + ": " + (Math.min(uncertain, S) + unconditionalSucc) + "\n"); } in.close(); out.close(); } }
0
3
A12852
A10939
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.*; public class Googlers { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("B-small-attempt0.in")); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); int nc = Integer.parseInt(in.readLine().trim()); for (int z=1; z<=nc; z++){ String[] line = in.readLine().trim().split("\\s+"); int n = Integer.parseInt(line[0]); int s = Integer.parseInt(line[1]); int p = Integer.parseInt(line[2]); int count = 0; for (int i = 0; i < n; i++) { int num = Integer.parseInt(line[3+i]); if (num>3*p-3) count++; else if ((num>=2)&&(num>=3*p-4)&&(s>0)) { count++; s--; } } out.println(String.format("Case #%d: %d", z,count)); } out.close(); } }
0
4
A12852
A11629
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.*; import java.util.*; public class B { public final static String FILE_IN = "B-small-attempt0.in"; public final static String FILE_OUT = "B-small-attempt0.out"; public static class Case { public int n, s, p; public int[] t; public String toString() { return "" + n + "," + s + "," + p + ":" + Arrays.toString(t); } } public static Case readCase(BufferedReader r) throws IOException { Case c = new Case(); String[] tk = r.readLine().split(" "); c.n = Integer.parseInt(tk[0]); c.s = Integer.parseInt(tk[1]); c.p = Integer.parseInt(tk[2]); c.t = new int[c.n]; for (int i=0; i<c.n; i++) { c.t[i] = Integer.parseInt(tk[3+i]); } return c; } public static void solveCase(Case c, BufferedWriter w, int index) throws IOException { int t = 0; int sr = c.s; for (int i=0; i<c.t.length; i++) { int q = c.t[i] / 3; int r = c.t[i] % 3; if (r == 0) { if (q >= c.p) { t++; } else if (q > 0 && q + 1 >= c.p && sr > 0) { t++; sr--; } } else if (r == 1) { if (q+1 >= c.p) { t++; } } else { if (q+1 >= c.p) { t++; } else if (q+2 >= c.p && sr > 0) { t++; sr--; } } } w.write("Case #" + (index+1) + ": " + t); w.newLine(); } public static void main(String[] args) throws Exception { BufferedReader r = new BufferedReader(new FileReader(FILE_IN)); BufferedWriter w = new BufferedWriter(new FileWriter(FILE_OUT)); int num = Integer.parseInt(r.readLine()); for (int i=0; i<num; i++) { Case c = readCase(r); solveCase(c, w, i); } w.close(); r.close(); } }
0
5
A12852
A12479
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Dancing { public static void main(String[] args){ List<String> input=new ArrayList<String>(); List<String> output=new ArrayList<String>(); try{ // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream("c:/input/B-small-attempt0.in"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console input.add(strLine); } //Close the input stream in.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } /*input done*/ for(int j=1;j<input.size();j++){ String a=input.get(j); //System.out.println("getting input as"+a); String b[]=a.split(" "); int n,s,p,t[]=null; n=Integer.parseInt(b[0]); s=Integer.parseInt(b[1]); p=Integer.parseInt(b[2]); t=new int[n]; for(int i=3;i<b.length;i++){ t[i-3]=Integer.parseInt(b[i]); } int count=0,div,mod; for(int i=0;i<t.length;i++){ div=t[i]/3; mod=t[i]%3; if(div>=p){ count++; //System.out.println("normal"+t[i]); }else if((div+Math.min(mod,1)>=p)){ count++; //System.out.println("with increment"+t[i]); }else if((div+Math.min(mod,2)>=p)&&(s>0)){ count++; if(mod>=2){ s--; //System.out.println("surprised"+t[i]+"remaining s"+s); } }else if((div+1>=p)&&(div>0)&&(s>0)){ count++; s--; //System.out.println("superficial"+t[i]); }else{ //System.out.println("noting happened"+t[i]+" div is "+div+"mod is"+mod); } } output.add(count+""); /*counting done*/ //System.out.println(count); } try { BufferedWriter bw = new BufferedWriter(new FileWriter(new File("C:/output/Dancing.out"), true)); for(int i=0;i<output.size();i++){ bw.write("Case #"+(i+1)+": "+output.get(i)); bw.newLine(); } bw.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } }
0
6
A12852
A10864
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package qualification; import java.io.FileInputStream; import java.io.IOException; import java.util.Scanner; public class Task2 { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(new FileInputStream("task21.txt")); int T = scanner.nextInt(); for (int i = 0; i < T; i++) { int N = scanner.nextInt(); int S = scanner.nextInt(); int p = scanner.nextInt(); int[] t = new int[N]; for (int j = 0; j < N; j++) { t[j] = scanner.nextInt(); } int noProbMin = Math.max(p * 3 - 2, p); int surpriseMin = Math.max(p * 3 - 4, p); int noProbCount = 0; int surpriseCount = 0; for (int googler : t) { if (googler >= noProbMin) { noProbCount++; } if (googler < noProbMin && googler >= surpriseMin) { surpriseCount++; } } surpriseCount = Math.min(surpriseCount, S); System.out.println("Case #" + (i + 1) + ": " + (noProbCount + surpriseCount)); } } }
0
7
A12852
A12641
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package codejam; import java.io.File; import java.io.PrintStream; import java.util.Scanner; public class QualificationB { public static void main(String[] args){ try{ Scanner sc=new Scanner(new File("B.in")); PrintStream ps=new PrintStream("B.out"); int t=sc.nextInt(); for(int i=0;i<t;i++){ int n=sc.nextInt(); int s=sc.nextInt(); int p=sc.nextInt(); int count=0; for(int j=0;j<n;j++){ int x=sc.nextInt(); if(x>(p-1)*3)count++; else if(x>1&&x>(p-1)*3-2&&s>0){ count++; s--; } } ps.println("Case #"+(i+1)+": "+count); } }catch(Exception e){ e.printStackTrace(); } } }
0
8
A12852
A12732
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; public abstract class FileWrapper { protected static final String CASE = "Case #"; protected static final String OUTPUT = "result.out"; protected int caseNum = 0; protected String output[] = null; private FileReader fr = null; private BufferedReader br = null; private FileWriter fw = null; private BufferedWriter bw = null; protected void openReadFile(String fileName) throws Exception { this.fr = new FileReader(fileName); this.br = new BufferedReader(this.fr); } protected void closeReadFile() throws Exception { this.br.close(); this.fr.close(); } protected String readLine() throws Exception { return this.br.readLine(); } protected boolean isFileReady() throws Exception { return this.br.ready(); } protected abstract void processInput(String fileName); private void openWriteFile(String fileName) throws Exception { this.fw = new FileWriter(fileName); this.bw = new BufferedWriter(this.fw); } private void closeWriteFile() throws Exception { this.bw.close(); this.fw.close(); } private void writeLine(String line) throws Exception { this.bw.write(line); this.bw.newLine(); } protected void processOutput(String fileName) { try{ this.openWriteFile(fileName); for (int i=0; i<this.caseNum; i++) { this.writeLine(this.output[i]); } this.closeWriteFile(); }catch(Exception e){} } protected abstract void calculate(); }
0
9
A12852
A10567
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package codejam; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Collection; import java.util.HashMap; import java.util.StringTokenizer; /** * * @author parusnik */ public class Codejam { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new FileReader("input.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt")); int T = Integer.parseInt(br.readLine()); StringTokenizer st; for (int t = 1; t<=T; t++){ bw.write("Case #" + String.valueOf(t) + ": "); st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int s = Integer.parseInt(st.nextToken()); int p = Integer.parseInt(st.nextToken()); int k = 0; int d = 0; for (int i = 0; i<n; i++){ int a = Integer.parseInt(st.nextToken()); a-=p; if (a>=0){ a/=2; if (a==p-2) k++; else if (a>p-2) d++; } } d += Math.min(k, s); bw.write(String.valueOf(d)); bw.newLine(); } br.close(); bw.close(); } }
0
10
A12852
A12822
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class Googlers { public static void main(String args[])throws IOException{ Scanner scan = new Scanner(new File(System.getProperty("user.dir")+"/input.in")); FileWriter file = new FileWriter("output.out"); int n=Integer.parseInt(scan.nextLine()); for(int j=0;j<n;j++){ int numGooglers = scan.nextInt(); int totalSurprising = scan.nextInt(); int p = scan.nextInt(); int[] totals = new int[numGooglers]; for(int i=0;i<numGooglers;i++){ totals[i]=scan.nextInt(); } int[] totalsMinus = new int[numGooglers]; for(int i=0;i<numGooglers;i++){ totalsMinus[i]=totals[i]-p; } int max =0; int surprising=0; for(int i=0;i<numGooglers;i++){ if(totalsMinus[i]>=0&&p-(int)Math.floor(totalsMinus[i]/2)<=2){ max++; if(p-(int)Math.floor(totalsMinus[i]/2)==2) surprising++; } } while(surprising>totalSurprising){ surprising--; max--; } file.write("Case #"+Integer.toString(j+1)+": "+Integer.toString(max)+"\r\n"); } file.close(); } }
0
11
A12852
A11834
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class B { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new File("B-small.in")); FileWriter fw = new FileWriter("B-small.out"); int T = in.nextInt(); for (int tc = 1; tc <= T; tc++) { int count = 0; int N = in.nextInt(); int S = in.nextInt(); int p = in.nextInt(); int[] totalScores = new int[N]; int special = 0; for(int i = 0; i < N; i++) { totalScores[i] = in.nextInt(); if(totalScores[i] >= 3) { int remainder = totalScores[i] % 3; int mid = totalScores[i] / 3; if(remainder == 0) {//mid mid mid or mid-1 mid mid+1; if(mid >= p) count++; else if(mid+1 >= p && special < S) { special++; count++; } } else if(remainder == 1) {//mid mid mid+1 or mid-1 mid+1 mid+1 if(mid >= p) count++; else if(mid+1 >= p) count++; } else {//mid mid+1 mid+1 or mid mid mid+2 if(mid >= p) count++; else if(mid+1 >= p) count++; else if(mid+2 >= p && special < S) { special++; count++; } } } else { if((totalScores[i] == 0 && p == 0) || (totalScores[i] == 1 && p <= 1)) count++; else if(totalScores[i] == 2) { if(p <=1) { count++; } else if(p == 2 && special < S) { special++; count++; } } } } fw.write ("Case #" + tc + ": " + count + "\n"); } fw.flush(); fw.close(); } }
0
12
A12852
A10693
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class googler { int cases; int googlers; int surprises; int goal; int[] points; /** * @param args */ public static void main(String[] args) { googler gag = new googler(); } public googler() { parseInput(); } //read in each case line by line. public void parseInput() { try { FileInputStream fstream = new FileInputStream("B-small-attempt4.in"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); FileWriter fwstream = new FileWriter("Googlers.out"); BufferedWriter out = new BufferedWriter(fwstream); cases = Integer.parseInt(br.readLine()); for (int i = 0; i < cases; i++) { solveCase(br.readLine(), i, out); } out.close(); } catch (Exception e) {//Catch exception if any System.err.println("Error: " + e.getMessage()); } } //parses variables for this case. public void solveCase(String caseArgs, int caseNum, BufferedWriter file) throws IOException { int y = 0; //the number of scores in this case above goal Scanner sc = new Scanner(caseArgs); googlers = sc.nextInt(); surprises = sc.nextInt(); goal = sc.nextInt(); points = new int[googlers]; int bestScore; // building the arrray of scores for (int i = 0; i < points.length; i++) points[i] = sc.nextInt(); //System.out.println("N:" + googlers + " S:" + surprises + " P:" + goal + " " + Arrays.toString(points)); for (int i = 0; i < points.length; i++) { if (unsurprising(points[i])) { y++; //chalk one up } else if (surprises > 0 && surprising(points[i])) { y++; surprises--; } } file.write("Case #" + (caseNum+1) + ": " + y + '\n'); //System.out.println(" Case #" + (caseNum+1) + ": " + y); } //returns best score if unsurprising public boolean unsurprising(int total) { //System.out.println(goal); int min = goal*3; min = min - 2; if (min <= 0) min = goal; //System.out.println("min: " + min + " total: " + total); return (total >= min); } public boolean surprising(int total) { int min = goal*3; min = min - 4; if (min <= 0) min = goal; //System.out.println("Smin: " + min + " Stotal: " + total); return (total >= min); } }
0
13
A12852
A10446
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
/* a = y b = n c = f d = i e = c f = w g = l h = b i = k j = u k = o l = m m = x n = s o = e p = v q = z r = p s = d t = r u = j v = g w = t x = h y = a z = q */ import java.util.*; public class Dancing { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); sc.nextLine(); for (int i = 0; i < T; i++) { int N = sc.nextInt(); int S = sc.nextInt(); int p = sc.nextInt(); int AWESOME = p + 2*(p-1); int SURP_GOOD = p + 2*(p-2); System.out.print("Case #" + (i + 1) + ": "); int goodOnes = 0; int[] curr = new int[N]; for (int j = 0; j < N; j++) { curr[j] = sc.nextInt(); } Arrays.sort(curr); for (int j = N-1; j >= 0; j--) { if (p == 0) goodOnes++; else if (curr[j] >= AWESOME && curr[j] > 0) goodOnes++; else if (curr[j] > 0 && S > 0 && curr[j] >= SURP_GOOD) { goodOnes++; S--; } } System.out.println(goodOnes); } } }
0
14
A12852
A12912
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package com.menzus.gcj._2012.qualification.b; import com.menzus.gcj.common.InputBlockParser; import com.menzus.gcj.common.OutputProducer; import com.menzus.gcj.common.impl.AbstractProcessorFactory; public class BProcessorFactory extends AbstractProcessorFactory<BInput, BOutputEntry> { public BProcessorFactory(String inputFileName) { super(inputFileName); } @Override protected InputBlockParser<BInput> createInputBlockParser() { return new BInputBlockParser(); } @Override protected OutputProducer<BInput, BOutputEntry> createOutputProducer() { return new BOutputProducer(); } }
0
15
A12852
A11119
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package jam; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; public class Dance { public static void main(String[] x)throws IOException{ File file=new File("A.in"); Writer output = null; File out=new File("A.out"); output = new BufferedWriter(new FileWriter(out)); BufferedReader fileIn = new BufferedReader(new FileReader(file)); String fileLine,delims,outs; String[] tokens; int cases,num,surprise,goal,ans,indA,indB,i; int [] items; fileLine=fileIn.readLine(); cases = Integer.parseInt(fileLine); delims = "[ ]+"; System.out.println("Cases = "+cases); for (i=0;i<cases;++i) { output.write("Case #"); output.write(Integer.toString(i+1)); output.write(": "); fileLine=fileIn.readLine(); tokens = fileLine.split(delims); num = Integer.parseInt(tokens[0]); surprise = Integer.parseInt(tokens[1]); goal = Integer.parseInt(tokens[2]); items = new int[tokens.length-3]; transfer(items,tokens); ans = solve(goal,surprise,items); output.write(Integer.toString(ans)); output.write("\r\n"); System.out.println(ans); } output.close(); } private static int solve(int goal, int surprise, int[] items) { int rej,acc,i,out,s; s = surprise; out = 0; rej = 3*goal-4; if(rej<1) { rej = 1; } acc = 3*goal-3; for(i=0;i<items.length;++i) { if(items[i]>acc) { ++out; } else if(items[i]>=rej&&s>0) { ++out; --s; } else { } } return out; } private static void transfer(int[] items, String[] tokens) { int size = tokens.length; int i = 3; for(i = 3;i<size;++i) { items[i-3] = Integer.parseInt(tokens[i]); } return; } }
0
16
A12852
A12957
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class QuestionB { public static void doPuzzle() { try { File questionfile = new File("B.in"); BufferedReader questionreader = new BufferedReader(new FileReader(questionfile)); File answerfile = new File("B.out"); PrintWriter answerwriter = new PrintWriter(new BufferedWriter(new FileWriter(answerfile))); String[] params = null; String question = questionreader.readLine(); int T = Integer.parseInt(question); int[][] table = makeTable(); for (int i = 0; i < T; i++) { question = questionreader.readLine(); params = question.split(" "); int N = Integer.parseInt(params[0]); int S = Integer.parseInt(params[1]); int p = Integer.parseInt(params[2]); int[] t = new int[N]; for (int j = 0; j < N; j++) t[j] = Integer.parseInt(params[3+j]); answerwriter.println("Case #" + (i+1) + ": " + analyze(table, N, S, p, t)); } answerwriter.close(); questionreader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); return; } catch (IOException e) { e.printStackTrace(); return; } } private static int[][] makeTable() { int[][] scoreTable = new int[31][11]; for (int i = 0; i < 31; i++) { if (i == 0) { for (int j = 0; j < 1; j++) scoreTable[i][j] = 2; for (int j = 1; j < 11; j++) scoreTable[i][j] = 0; continue; } if (i == 1) { for (int j = 0; j < 2; j++) scoreTable[i][j] = 2; for (int j = 2; j < 11; j++) scoreTable[i][j] = 0; continue; } if (i >= 28) { for (int j = 0; j < 11; j++) scoreTable[i][j] = 2; continue; } int shou = i / 3; int amari = i % 3; switch (amari) { case 0: for (int j = 0; j < shou+1; j++) scoreTable[i][j] = 2; scoreTable[i][shou+1] = 1; for (int j = shou+2; j < 11; j++) scoreTable[i][j] = 0; break; case 1: for (int j = 0; j < shou+2; j++) scoreTable[i][j] = 2; for (int j = shou+2; j < 11; j++) scoreTable[i][j] = 0; break; case 2: for (int j = 0; j < shou+2; j++) scoreTable[i][j] = 2; scoreTable[i][shou+2] = 1; for (int j = shou+3; j < 11; j++) scoreTable[i][j] = 0; break; } } return scoreTable; } private static int analyze(int[][] table, int N, int S, int p, int[] t) { int[] count = new int[3]; for (int i = 0; i < t.length; i++) { count[table[t[i]][p]]++; } int border = (count[1] < S) ? count[1] : S; return count[2] + border; } }
0
17
A12852
A10950
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; public class Writer { private String fileName; private BufferedWriter writer; private int i = 1; public Writer(String fileName){ this.fileName = fileName; } public void open() throws Exception{ writer = new BufferedWriter(new FileWriter(new File(fileName))); } public void close() throws Exception{ writer.close(); } public void write(String erg) throws Exception{ writer.write("Case #" + i +": " + erg + "\n"); i++; } }
0
18
A12852
A12132
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.*; import java.util.*; /** * Auto Generated Java Class. */ public class Problem_b { public static void main(String[] args) { String [] nums=getWords("B-small-attempt0.in"); int t=Integer.parseInt(nums[0]); for(int i=1;i<nums.length;i++){ String [] tempstr=nums[i].split(" "); int [] temp= new int[tempstr.length]; for(int x=0;x<tempstr.length;x++){ temp[x]=Integer.parseInt(tempstr[x]); } System.out.println("Case #" +i+": "+ check(temp)); } } public static int check(int [] a){ int gnum=a[0]; int surp=a[1]; int p=a[2]; int [] scores=new int [gnum]; for(int i=3;i<a.length;i++){ scores[i-3]=a[i]; } // for(int x:scores) // System.out.print(x+" "); //System.out.println(gnum+" "+surp+" "+p); int max=0; int tempsurps=0; for(int i=0;i<scores.length;i++){ if(scores[i]/3.0 > p-1){ max++; } else if(tempsurps<surp && p-scores[i]/3.0 <= 1.5 && scores[i]!=0){ max++; tempsurps++; } } return max; } public static String [] getWords( String filename ) { String [] list = null; try { Scanner read = new Scanner( new File( filename ) ); int count = 0; while ( read.hasNext() ){ String temp = read.nextLine(); count++; } list = new String[ count ]; read = new Scanner( new File( filename ) ); count = 0; while ( read.hasNext() ){ list[count] = read.nextLine(); count++; } } catch ( IOException e1 ) { System.out.println( "problem reading file" ); } return list; } /* ADD YOUR CODE HERE */ }
0
19
A12852
A10122
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package t2; import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; public class T1 { BufferedWriter out; ArrayList<String> list = new ArrayList<String>(); int i = 1; T1(){ try { out = new BufferedWriter(new FileWriter(new File("output.txt"))); } catch (IOException ex) {} start(); try { out.close(); } catch (IOException ex) { Logger.getLogger(T1.class.getName()).log(Level.SEVERE, null, ex); } } public static void main(String[] args) { T1 t = new T1(); } private void lerArquivo(String input) { File f = new File(input); if(!f.exists()) { System.exit(-1); } try { BufferedReader in = new BufferedReader(new FileReader(f)); String line; int lineCount = 0; in.readLine(); while((line = in.readLine())!=null) { list.add(line); } } catch (Exception e) {} } private void write(String str){ str = "Case #"+i+": "+ str + "\n"; try { out.write(str, 0, str.length()); i++; } catch (IOException ex) { Logger.getLogger(T1.class.getName()).log(Level.SEVERE, null, ex); } } private void start(){ lerArquivo("input.txt"); for(String str: list){ int counter = 0; StringTokenizer st = new StringTokenizer(str); int googlers = Integer.parseInt(st.nextToken()); int surprising = Integer.parseInt(st.nextToken()); int p = Integer.parseInt(st.nextToken()); for(int i = 0; i < googlers; i++){ int score = Integer.parseInt(st.nextToken()); int base = score / 3; if(base >=p) counter++; else if(base == 0){ if(score >= p && score == 1){ counter++; }else if (score >= p && score == 2 && surprising > 0){ counter++; surprising--; } }else if(score%3 == 0){ if(base+1 >= p && surprising > 0){ surprising--; counter++; } }else if((score % 3) == 1){ if(base+1 >= p) counter++; }else if((score%3) == 2){ if(base+1 >= p){ counter++; }else if(base+2 >= p && surprising > 0){ counter++; surprising--; } } } write(""+counter); } } }
0
20
A12852
A12716
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package com.dagova.dancingWithTheGooglers; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class DancingWithTheGooglers { /** * @param args */ public static void main(String[] args) { DancingWithTheGooglersSolver solver; BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int testCasesNumber = 0; try { testCasesNumber = Integer.parseInt(bufferedReader.readLine()); for(int testCase = 0; testCase < testCasesNumber; testCase++) { solver = new DancingWithTheGooglersSolver(); int solution = solver.solve(bufferedReader.readLine()); System.out.println("Case #" + (testCase+1) + ": "+solution); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
0
21
A12852
A13230
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package com.eevoskos.codejam; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class DancingWithTheGooglers { static boolean DEBUG = false; class Googler implements Comparable<Googler> { List<Triplet> triplets; public Googler(List<Triplet> triplets) { Collections.sort(triplets); this.triplets = triplets; } List<Triplet> getSuprisingTriplets() { List<Triplet> surprising = new ArrayList<Triplet>(); for (Triplet t : triplets) { if (t.isSurprising()) { surprising.add(t); } } return surprising; } Triplet bestScoreTriplet() { Collections.sort(triplets); return triplets.get(0); } @Override public int compareTo(Googler another) { return this.bestScoreTriplet().compareTo(another.bestScoreTriplet()); } List<Triplet> tripletsWithBestScoreAtLeast(int p) { List<Triplet> list = new ArrayList<Triplet>(); for (Triplet t : triplets) { if (t.bestResult() >= p) { list.add(t); } } return list; } int[] numOftripletsWithBestScoreAtLeast(int p) { // result[0]: number of triplets // result[1]: number of the triplets that are surprising int[] result = new int[2]; result[0] = 0; result[1] = 0; for (Triplet t : triplets) { if (t.bestResult() >= p) { result[0]++; if (t.isSurprising()) { result[1]++; } } } return result; } } class Triplet implements Comparable<Triplet> { int x, y, z; Triplet(int x, int y, int z) { int[] n = new int[] { x, y, z }; Arrays.sort(n); this.x = n[0]; this.y = n[1]; this.z = n[2]; } int sum() { return x + y + z; } @Override public boolean equals(Object obj) { if (obj == null) return false; if (!(obj instanceof Triplet)) return false; return x == ((Triplet) obj).x && y == ((Triplet) obj).y && z == ((Triplet) obj).z; } boolean isSurprising() { int[] n = new int[] {x, y, z}; Arrays.sort(n); return n[2] - n[0] == 2; } @Override public String toString() { String s = x + " " + y + " " + z; if (isSurprising()) { s += " (*)"; } return s; } int bestResult() { return z; } @Override public int compareTo(Triplet another) { if (this.bestResult() > another.bestResult()) { return 1; } else if (this.bestResult() < another.bestResult()) { return -1; } else { return 0; } } } int solveCase(String input) { String[] args = input.split(" "); // Number of Googlers int N = Integer.valueOf(args[0]); // Number of surprising triplets int S = Integer.valueOf(args[1]); // Min best score int p = Integer.valueOf(args[2]); // Total points of Googlers int[] t = new int[args.length - 3]; for (int i = 0; i < t.length; i++) { t[i] = Integer.valueOf(args[i + 3]); } if (DEBUG) printInput(N, S, p, t); return calcResult(N, S, p, t); } int calcResult(int N, int S, int p, int[] t) { int result = 0; List<Googler> googlers = new ArrayList<Googler>(); // For each Googler for (int i = 0; i < N; i++) { // Calculate possible combinations of scores List<Triplet> triplets = getCombinations(t[i]); googlers.add(new Googler(triplets)); if (DEBUG) { System.out.println("Googler #" + (i + 1)); for (Triplet tri : triplets) { System.out.println(tri); } System.out.println(""); } } // Sort by best score Collections.sort(googlers); int surprising = 0; for (Googler g : googlers) { List<Triplet> qt = g.tripletsWithBestScoreAtLeast(p); boolean finishThis = false; for (Triplet tri : qt) { if (finishThis) { continue; } else if (!tri.isSurprising()) { result++; finishThis = true; continue; } else { if (surprising >= S) { continue; } else { surprising++; result++; finishThis = true; continue; } } } } return result; } List<Triplet> getCombinations(int sum) { List<Triplet> triplets = new ArrayList<Triplet>(); for (int x = 0; x <= 10; x++) { for (int y = 0; y <= 10; y++) { for (int z = 0; z <= 10; z++) { Triplet triplet = new Triplet(x, y, z); if (triplet.sum() == sum) { if (triplet.z - triplet.x > 2) { // Impossible case, skip continue; } else if(triplets.contains(triplet)) { // Don't add if duplicate continue; } else { triplets.add(triplet); } } else { // Sum is not proper, skip continue; } } } } return triplets; } static int factorial(int n) { if (n <= 1) { return 1; } else { return n * factorial(n - 1); } } static void printInput(int N, int S, int p, int[] t) { String output = "\n"; output += N + " Googlers, "; output += S + " surprising results. "; output += "How many had best score equal to or greater than " + p + "? "; output += "(scores: "; for (int i = 0; i < t.length; i++) { if (i != 0) { output += ", "; } output += t[i]; } output += ")"; System.out.println(output); } public static void main(String... args) { DancingWithTheGooglers dancing = new DancingWithTheGooglers(); try { BufferedReader c = new BufferedReader(new InputStreamReader(System.in)); // Number of test cases int T = Integer.valueOf(c.readLine()); System.out.println(); // Do, for each test case for (int i = 0; i < T; i++) { // Googlerese string String input = c.readLine(); // Process input int output = dancing.solveCase(input); // Print the translated text System.out.println("Case #" + (i + 1) + ": " + output); } } catch (Exception e) { e.printStackTrace(); } } }
0
22
A12852
A11289
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.StringTokenizer; public class C implements Runnable { private StringTokenizer st; private BufferedReader in; private PrintWriter out; final String file = "C-small"; Map<Character, Character> cache = new HashMap<Character, Character>(); public void solve(int test) throws IOException { out.print("Case #" + (test + 1) + ": "); if (test == 52) { System.out.println(); } // ======================================================================= int totalEmp = nextInt(); int surprise = nextInt(); int threshold = nextInt(); int ans = 0; List<Integer> scores = new ArrayList<Integer>(); for (int i = 0; i < totalEmp; i++) scores.add(nextInt()); if (threshold == 0) { out.println(String.valueOf(totalEmp)); return; } Collections.sort(scores); int min = (threshold * 3) - 4; min = Math.max(min, 0); for (int i : scores) { if(threshold > i) continue; if (i >= (threshold) * 3 - 2) { ans++; continue; } if ((i == 1) && threshold <= i) { ans++; continue; } if (surprise > 0 && i >= (threshold * 3) - 4) { surprise--; ans++; continue; } } // ======================================================================= out.println(String.valueOf(ans)); } public void run() { try { //in = new BufferedReader(new FileReader( // "C:\\Vinay\\gcj\\GCJ\\src\\C-small.in")); //out = new PrintWriter("C:\\Vinay\\gcj\\GCJ\\src\\C-small.out"); in = new BufferedReader(new FileReader(file + ".in")); out = new PrintWriter(file + ".out"); eat(""); int tests = nextInt(); for (int test = 0; test < tests; ++test) { solve(test); } out.close(); } catch (Exception e) { e.printStackTrace(); failed = true; } } void eat(String s) { st = new StringTokenizer(s); } String next() throws IOException { while (!st.hasMoreTokens()) { String line = in.readLine(); if (line == null) { return null; } eat(line); } return st.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } static boolean failed = false; public static void main(String[] args) { Locale.setDefault(Locale.US); Thread th = new Thread(new C()); th.start(); try { th.join(); } catch (InterruptedException iex) { } if (failed) { throw new RuntimeException(); } } }
0
23
A12852
A10928
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package CodeJam; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class B { /** * @param args */ static Scanner scan = new Scanner(System.in); static BufferedReader brscan = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw ; static ArrayList<Triplet> arrTriplet = new ArrayList<Triplet>(1000); public static void main(String[] args) throws NumberFormatException, IOException { pw = new PrintWriter("output-B.txt"); // TODO Auto-generated method stub int tc = scan.nextInt(); int googler, surprise, minscore; for (int x=1; x<=tc; x++) { arrTriplet.clear(); googler = scan.nextInt(); surprise = scan.nextInt(); minscore = scan.nextInt(); for (int n = 0; n<googler; n++ ) { arrTriplet.add(ScoreToTriplet(scan.nextInt())); } Collections.sort(arrTriplet); // process // int pass = 0; for (int n = 0; n<googler; n++) { Triplet now = arrTriplet.get(n); if (now.getMax()>=minscore) { pass++; } else if (surprise>0){ if (now.x == now.y && now.y == now.z) { if (now.x+1>=minscore && now.y>0) { pass++; surprise--; } } else if (now.x == now.y) { if (now.x+1>=minscore && now.y>0) { pass++; surprise--; } } } } //debug(); pw.println("Case #"+x+": "+pass); } pw.flush(); pw.close(); } public static void debug() { for (int n=0; n<arrTriplet.size(); n++) { pw.println(arrTriplet.get(n).toString()); } } public static Triplet ScoreToTriplet(int score) { int average = score/3; int remain = score-average*3; if (remain==2) { return new Triplet(average+1, average+1, average); } else if (remain==1) { return new Triplet(average+1, average, average); } else { return new Triplet(average, average, average); } } } class Triplet implements Comparable<Triplet> { int x, y, z; public Triplet(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } @Override public int compareTo(Triplet o) { // TODO Auto-generated method stub if (this.x!=o.x) { return o.x-this.x; } if (this.y!=o.y) { return o.y-this.y; } if (this.z!=o.z) { return o.z-this.z; } return 0; } public int getMax() { if (x>=y && x>=z) { return x; } if (y>=x && y>=z) { return y; } return z; } public int getMin() { if (x<=y && x<=z) { return x; } if (y<=z && y<=x) { return y; } return z; } public String toString() { return "["+x+","+y+","+z+"]"; } }
0
24
A12852
A12621
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Googlers { public static void main(String[] args) throws FileNotFoundException { new Googlers().doProcessing(new File("D:\\codejam\\B\\small.txt")); } public void doProcessing(File inputFile) throws FileNotFoundException { Scanner scanner = new Scanner(inputFile).useDelimiter("\n"); if (scanner != null) { int totalCases = Integer.parseInt(scanner.next().trim()); int k = 1 ; if (totalCases > 0) { while (scanner.hasNext()) { String[] rowValues = scanner.next().trim().split(" "); int totalGooglers = Integer.parseInt(rowValues[0]); // System.out.println("Total Googlers : " + totalGooglers); int totalSuprisingCases = Integer.parseInt(rowValues[1]); // System.out.println("Total Surprising Cases : " + // totalSuprisingCases); int averageScore = Integer.parseInt(rowValues[2]); // System.out.println("Total Success Cases : " + // averageScore); // System.out.println("Total Length : " + rowValues.length); int[] totalMarks = new int[totalGooglers]; int j = 0; for (int i = 3; i < rowValues.length; i++) { totalMarks[j] = Integer.parseInt(rowValues[i].trim()); // System.out.println("Value Put : " + totalMarks[j]); j++; } int successCase = getSuccessCase(totalGooglers, averageScore, totalSuprisingCases, totalMarks); System.out.println("Case #" + k++ + ": " + successCase); } } } scanner.close(); } public boolean doNormalCase(int totalScore, int averageScore) { boolean success = false; int X3value = averageScore * 3; if (totalScore >= X3value) { success = true; } else if ((totalScore >= X3value - 1) || (totalScore >= X3value + 1)) { success = true; } else if ((totalScore >= X3value - 2) || (totalScore >= X3value + 2)) { success = true; } else { success = false; } return success; } public boolean doSurprisingCase(int totalScore, int averageScore) { boolean success = false; int X3value = averageScore * 3; // System.out.println("Total Score : " + totalScore); // System.out.println("Average Score : " + X3value); if (((totalScore >= X3value - 3) || (totalScore >= X3value + 3)) && totalScore > averageScore) { success = true; } else if (((totalScore >= X3value - 4) || (totalScore >= X3value + 4)) && totalScore > averageScore) { success = true; } else { success = false; } return success; } public int getSuccessCase(int totalCses, int averageScore, int surprisingCase, int[] caseValues) { int totalSuccess = 0; for (int i = 0; i < totalCses; i++) { // System.out.println("----------------------Value Put : " + // totalCses); boolean normalCaseSuccess = doNormalCase(caseValues[i], averageScore); if (!normalCaseSuccess) { if (surprisingCase > 0) { boolean surprisingCaseSuccess = doSurprisingCase( caseValues[i], averageScore); if (surprisingCaseSuccess) { // System.out.println("Surprising Success..." + // caseValues[i]); totalSuccess++; surprisingCase--; } } } else { totalSuccess++; } } return totalSuccess; } }
0
25
A12852
A12335
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
/** * Program : Test for google code jam * Author : jenogg * Since : 2012.04.14 */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class Subject0102 { /** Mapping map */ private Map<String, String> mapper; /** * Construct */ public Subject0102() { init(); } /** * Initialize. */ private void init() { /* Input 3 ejp mysljylc kd kxveddknmc re jsicpdrysi rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd de kr kd eoya kw aej tysr re ujdr lkgc jv Output Case #1: our language is impossible to understand Case #2: there are twenty six factorial possibilities Case #3: so it is okay if you want to just give up */ String input = " abcdefghijklmnopqrstuvwxyz"; String output = " yhesocvxduiglbkrztnwjpfmaq"; mapper = new HashMap<String, String>(); for (int letter=0; letter < input.length(); letter++) { mapper.put(input.substring(letter,letter+1), output.substring(letter,letter+1)); } } /** * Test */ public void test() { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String systemIn; int sentenceSize = 0; String[] sentence = new String[]{}; try { //println("Input"); systemIn = nvl(in.readLine()); sentenceSize = getSentenceSize(systemIn); if (sentenceSize > 0) { sentence = new String[sentenceSize]; for (int index = 0; index < sentenceSize; index++) { systemIn = in.readLine(); sentence[index] = nvl(systemIn); } //println("\n-------------------------------------------\n"); in.close(); //println("Output"); for (int index = 0; index < sentenceSize; index++) { print("Case #" + (index+1) + ": "); printSentence(sentence[index]); } } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } /** * Gets size of sentences * @param sentenceSize Sentence size * @return Size of sentences * @throws Exception */ private int getSentenceSize(String sentenceSize) throws Exception { return Integer.parseInt(nvl(sentenceSize, "0")); } /** * Print mapping sentence * @param sentence Source sentence */ private void printSentence(String sentence) { int success = 0; String[] data = sentence.split(" "); int dancers = Integer.parseInt(data[0]); int suprise = Integer.parseInt(data[1]); int cutline = Integer.parseInt(data[2]); if (cutline == 0) { success = dancers; } else { for (int index=0; index < dancers; index++) { int totalPoint = Integer.parseInt(data[3+index]); if (totalPoint == 0) { continue; } int basePoint = totalPoint / 3; int rest = totalPoint % 3; int canPoint = basePoint; if (rest != 0) { canPoint++; } if (canPoint >= cutline) { success++; continue; } if (suprise > 0) { if (rest != 1) { canPoint++; if (canPoint >= cutline) { success++; suprise--; continue; } } } } } println(success); } /** * Replace null to empty string * @param string Input value of string * @return If input string is null then empty string, otherwise trimmed input string */ private String nvl(String string) { return nvl(string, ""); } /** * Replace null to replace string * @param string Input value of string * @param replace Replace value of string * @return If input string is null then empty string, otherwise trimmed input string */ private String nvl(String string, String replace) { return string == null ? "" : string.trim(); } /** * Print out * @param obj Value of object */ private void print(Object obj) { System.out.print(obj); } /** * Print line out */ private void println() { println(""); } /** * Print line out * @param obj Value of object */ private void println(Object obj) { System.out.println(obj); } /** * main * @param args Arguments */ public static void main(String[] args) { Subject0102 subject = new Subject0102(); subject.test(); } }
0
26
A12852
A12931
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package google.loader; import java.util.List; public interface ChallengeReader { List<Challenge> createChallenges(String[] lines); }
0
27
A12852
A11261
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; public class Dancers { public static void main (String args[]){ if (args.length != 1){ System.out.println ("Gimme the right arguments!"); return; } File f = new File(args[0]); int testcases, surprise, p, n; ArrayList <Integer> scores = new ArrayList <Integer>(); try{ BufferedReader in = new BufferedReader (new FileReader(f)); String s; testcases = Integer.parseInt(in.readLine()); for (int i = 1; i<=testcases; i++){ scores.clear(); s = in.readLine(); String temp [] = s.split(" "); n= Integer.parseInt (temp[0]); surprise = Integer.parseInt(temp[1]); p = Integer.parseInt(temp[2]); for (int j =3; j<temp.length; j++){ scores.add(Integer.parseInt(temp[j])); } int count = 0; int countSpecial =0; for (int a : scores){ boolean sp = true; boolean found = false; for (int q = p; q<=10; q++){ int t = a - q; if(t >=0){ int l = t/2; int h = t - l; if (Math.abs(q - l) <=2 && Math.abs(q - h) <=2){ // System.out.println(a + " " + + q + " " + t + " " + l + " " + h) ; if (Math.abs(q - l) <2 && (Math.abs(q - h) <2)){ sp = false; // System.out.println("reg"); } found = true; } } } if (found){ count ++; if (sp){ countSpecial++; // System.out.println("hi"); } } } //System.out.println(count + " " + countSpecial); if (countSpecial > surprise){ count -= (countSpecial - surprise); } System.out.printf ("Case #%d: %d\n", i, count ); } } catch (IOException e){ } } }
0
28
A12852
A10345
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.PrintWriter; public class B { public static void main (String[] args) { try { //BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("src/B-small-attempt0.in")))); PrintWriter pw = new PrintWriter(System.out); int cases = Integer.parseInt(in.readLine()); for (int i = 0; i < cases; i++) { int max=0; String[] data = in.readLine().split(" "); int N = Integer.parseInt(data[0]); int S = Integer.parseInt(data[1]); int p = Integer.parseInt(data[2]); int[] sums = new int[N]; for (int j = 0; j < N; j++) { sums[j] = Integer.parseInt(data[j+3]); } if(p==0) { max=N; } else if (p==1) { for (int j = 0; j < sums.length; j++) { if(sums[j]>0) max++; } } else{ for (int j = 0; j < sums.length; j++) { if(sums[j]>=3*p-2) max++; else if(sums[j]>=3*p-4 && S>0) { max++; S--; } } } System.out.println("Case #"+(i+1)+": "+max); } pw.flush(); } catch(Exception e) { e.printStackTrace(); } } }
0
29
A12852
A12533
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package google; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; public class Dancing { public static void main(String[] args) throws FileNotFoundException, IOException { IO.changeGoogleIO('B', 0); Scanner input = new Scanner(System.in); int T = input.nextInt(); int N, S, p, min, now; int result0; String result; for (int i = 0; i < T; ++i) { result = "Case #" + (i + 1) + ": "; result0 = 0; N = input.nextInt(); S = input.nextInt(); p = input.nextInt(); min = 3 * (p - 1); for (int j = 0; j < N; ++j) { now = input.nextInt(); if (now > min) ++result0; else if ((now > (min - 2)) && (now > 0) && (S > 0)) { ++result0; --S; } } result += result0; System.out.println(result); } } }
0
30
A12852
A10009
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.*; import java.math.BigInteger; import java.util.*; public class r2a { int surprises = 0; int p = 0; int elems[] = new int[100]; int output = 0; /** * @param args */ public static void main(String[] args) { r2a mk = new r2a(); try { FileInputStream fstream = new FileInputStream("d:/cjinput.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String str; int i = 0; while ((str = br.readLine()) != null) { int numOfElems = 0; mk.output = 0; i++; if (i == 1) continue; StringTokenizer strTok = new StringTokenizer(str, " "); while (strTok.hasMoreTokens()) { numOfElems = Integer.parseInt(((String) strTok.nextToken())); mk.surprises = Integer.parseInt(((String) strTok.nextToken())); mk.p = Integer.parseInt(((String) strTok.nextToken())); for (int x = 0; x < numOfElems; x++) { mk.elems[x] = Integer.parseInt(((String) strTok.nextToken())); } } mk.evaluate(i,numOfElems); } in.close(); } catch (Exception e) { System.err.println(e); } } private void evaluate(int rowNum, int numOfElems) { for (int i = 0; i< numOfElems; i++) { if (isValidTotal(elems[i])) output++; } String outputStr = "Case #" + (rowNum -1) + ": " + output; System.out.println(outputStr); } private boolean isValidTotal(int num) { if (p==0) return true; if (num != 0) { int maxVal = 3*p; if (num >= maxVal-2) return true; if (num >= maxVal-4 && surprises > 0) { surprises--; return true; } } return false; } }
0
31
A12852
A10386
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Dancing { private static BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { String line = bufferedReader.readLine(); int cases = Integer.parseInt(line); for (int i = 1; i <= cases; i++) { line = bufferedReader.readLine(); String[] split = line.split(" "); int googlers = Integer.parseInt(split[0]); int surprises = Integer.parseInt(split[1]); int p = Integer.parseInt(split[2]); int[] totals = new int[googlers]; for (int j = 0; j < googlers; j++) { totals[j] = Integer.parseInt(split[3 + j]); } Arrays.sort(totals); int answer = 0; int usedSurprises = 0; for (int j = 0; j < googlers; j++) { if (p == 0) { answer++; } else if (totals[j] >= p + 2 * (p - 1) && p >= 1) { answer++; } else if (usedSurprises < surprises) { if (totals[j] >= p + 2 * (p - 2) && p >= 2) { answer++; usedSurprises++; } } } System.out.println("Case #" + i + ": " + answer); } } }
0
32
A12852
A12300
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { List<String> lstLinesOutput = new ArrayList<String>(); List<String> lstLinesInput = FileReaderHandler.openFile("/home/guillaume/Bureau/input"); for(int n=1;n< Integer.parseInt(lstLinesInput.get(0)) + 1;n++){ System.out.println("Case " + n); String sOutput = "Case #" + n + ": "; String sInput = lstLinesInput.get(n); String[] hInput = sInput.split(" "); //to int array int[] iInput = new int[hInput.length]; for(int i=0;i < hInput.length;i++){ iInput[i] = Integer.parseInt(hInput[i]); } int iNbSurprising = iInput[1]; int iToBeat = iInput[2]; int iNbAnswers = 0; for(int i=0;i<iInput[0];i++){ int iScore = iInput[i+3]; if(iScore > 0){ int iBase = iScore/3; int iReste = iScore%3; if(iBase >= iToBeat || iReste > 0 && iBase + 1 >= iToBeat){ iNbAnswers++; }else if(iNbSurprising > 0 && (iReste == 0 && iBase + 1 >= iToBeat || iReste == 2 && iBase + 2 >= iToBeat)){ iNbAnswers++; iNbSurprising--; } } else if(iToBeat == 0){ iNbAnswers++; } } sOutput += iNbAnswers; lstLinesOutput.add(sOutput); } if(Integer.parseInt(lstLinesInput.get(0)) != lstLinesOutput.size()){ System.out.println("ERROR!!!"); } FileWriterHandler.writeToFile(lstLinesOutput); } }
0
33
A12852
A12149
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.*; import java.util.*; public class B { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int[] best_no_surprise = {0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10}; int[] best_surprise = {0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10}; int T = Integer.parseInt(in.readLine()); for (int t = 0; t < T; t++) { StringTokenizer st = new StringTokenizer(in.readLine()); int N = Integer.parseInt(st.nextToken()); int S = Integer.parseInt(st.nextToken()); int p = Integer.parseInt(st.nextToken()); int[] a = new int[N]; for (int i = 0; i < N; i++) a[i] = Integer.parseInt(st.nextToken()); /*System.out.print(N + " " + S + " " + p); for (int i = 0; i < N; i++) System.out.print(" " + a[i]); System.out.println();*/ int n_over_p = 0; int n_surp = 0; for (int i = 0; i < N; i++) { if (best_no_surprise[a[i]] >= p) n_over_p++; if (best_no_surprise[a[i]] < p && best_surprise[a[i]] >= p) n_surp++; } int max_val = n_over_p + Math.min(S, n_surp); System.out.println("Case #"+(t+1)+": " + max_val); } in.close(); } static void init () { } }
0
34
A12852
A11999
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStreamReader; public class Program { /** * @param args */ public static void main1(String[] args) { Speaking_in_Tongues sit=new Speaking_in_Tongues(); sit.initialize(); sit.register("our language is impossible to understand", "ejp mysljylc kd kxveddknmc re jsicpdrysi"); sit.register("there are twenty six factorial possibilities", "rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd"); sit.register("so it is okay if you want to just give up", "de kr kd eoya kw aej tysr re ujdr lkgc jv"); for(char o='a';o<= 'z';o++) { System.out.print(sit.map[o]); } try { FileWriter fileWriter=new FileWriter("A-small-attempt0.out"); FileReader fileReader=new FileReader("A-small-attempt0.in"); BufferedReader in = new BufferedReader(fileReader); int T= Integer.parseInt(in.readLine()); for(int t=1;t<=T;t++) { String translated=in.readLine(); String normal= sit.Solve(translated); fileWriter.write("Case #"+t+": "+normal+"\n"); } fileWriter.close(); fileReader.close(); } catch (Exception e) { System.out.println("Error! Exception: "+e); } } public static void main(String[] args) { try { FileWriter fileWriter=new FileWriter("B-small-attempt4.out"); FileReader fileReader=new FileReader("B-small-attempt4.in"); BufferedReader in = new BufferedReader(fileReader); int T= Integer.parseInt(in.readLine()); for(int t=1;t<=T;t++) { String[] tokens= in.readLine().split(" "); int N= Integer.parseInt(tokens[0]); int[] values=new int[N]; int S= Integer.parseInt(tokens[1]); int p= Integer.parseInt(tokens[2]); for(int n=0;n<N;n++) { values[n]= Integer.parseInt(tokens[n+3]); } Dancing_With_the_Googlers d=new Dancing_With_the_Googlers(); int result=d.solve1(S, p, values); fileWriter.write("Case #"+t +": " +result+"\n"); } fileWriter.close(); fileReader.close(); } catch (Exception e) { System.out.println("Error! Exception: "+e); } } }
0
35
A12852
A11214
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package problemb; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class DancingWithTheGooglers { public static void main(String[] args) { int T = 1; String G = ""; String[] inputs; BufferedReader reader; reader = new BufferedReader(new InputStreamReader(System.in)); try { T = Integer.parseInt(reader.readLine()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } StringBuffer buffer = new StringBuffer(); for (int X = 1; X <= T; X++) { try { G = reader.readLine(); inputs = G.split(" "); int N = Integer.parseInt(inputs[0]); int S = Integer.parseInt(inputs[1]); int p = Integer.parseInt(inputs[2]); int[] t; if (inputs.length - 3 > N) { t = new int[N]; } else { t = new int[inputs.length - 3]; } for (int i = 0; i < t.length; i++) { t[i] = Integer.parseInt(inputs[i + 3]); } int surprizing = 0; Arrays.sort(t); int result = 0; for (int j = t.length - 1; j >= 0; j--) { if(p==0){ result = t.length; break; } int dev = t[j] / 3; int mod = t[j] % 3; if (dev >= p) { result++; continue; } if (mod == 1 && dev + 1 >= p) { result++; continue; } if (mod == 2 && dev + 1 >= p) { result++; continue; } if (mod == 2 && dev + 2 >= p && surprizing < S) { surprizing++; result++; continue; } if (mod == 0 && dev > 0 && dev + 1 >= p && surprizing < S) { surprizing++; result++; continue; } } buffer.append("Case #").append(X).append(": ").append(result) .append("\r\n"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println(buffer.toString()); } }
0
36
A12852
A10547
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.PrintStream; public class Dance { static int getMaxGooglers(int N,int S, int p, int[] t) { int count=0; int surpriseCount=0; int avg=p*3; for(int i=0;i<N;i++) { if(t[i]>=p) { if(t[i]>=avg-2) count++; else if(surpriseCount<S) { if(t[i]>=avg-4) { count++; surpriseCount++; } } } } return count; } }
0
37
A12852
A12925
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package google.contest.C; import google.loader.Challenge; import google.problems.AbstractChallenge; import java.util.HashSet; import java.util.Set; public class CChallenge extends AbstractChallenge implements Challenge { private int B; private int A; private int num; Set<String>pairs ; public CChallenge(int number, String line) { super(number); num=0; pairs = new HashSet<String>(); String[] tokens = line.split(" "); A = Integer.parseInt(tokens[0]); B = Integer.parseInt(tokens[1]); int i=0; for( i=A ; i<=B; i++){ calcFor(i); } setResult(""+num); } private void calcFor(int i) { String numString = ""+i; for(int j=1; j<= numString.length()-1; j++){ String first = numString.substring(0,j); String second = numString.substring(j); String third = second+first; check(i, third); } } private void check(int i, String third) { if(third.startsWith("0")){ return; } int j = Integer.parseInt(third); if(A<=i && i<j && j<=B){ String hlp = ""+i+j; if(! pairs.contains(hlp)){ pairs.add(hlp); num++; }else{ System.out.println(""+num+" "+i+" "+j); } } } }
0
38
A12852
A11675
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package jam_b; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author dkozyrev */ public class Jam_B { /** * @param args the command line arguments */ public static void main(String[] args) { List<Map> cases = readFile("C:\\tmp\\testA.txt"); int counter = 1; String delimiter = " "; for (Map<String, String> caseItem : cases) { List<String> lines = Arrays.asList(caseItem.get("str").split(delimiter)); int res = findMax(lines); System.out.println("Case #"+counter+":" + res); counter++; } } public static int findMax(List<String> lines) { int max = 0; int peaopleNum = Integer.parseInt(lines.get(0)); int surprising = Integer.parseInt(lines.get(1)); int find = Integer.parseInt(lines.get(2)); //System.out.println(find); int counter = 0; for(String score : lines) { if(counter > 2) { //find potential Double scoreD = Double.parseDouble(score); if(scoreD/3 >= (find-0.75)) { max++; //System.out.println("1: " + scoreD/3); } else if (surprising>=1 && (scoreD/3 > (find-1.5)) && (find-1.5) > 0 ) { max++; surprising--; //System.out.println("2: " + scoreD/3); } } counter++; //System.out.println(max); } return max; } public static List<Map> readFile(String fname) { List<Map> casesList = new ArrayList<Map>(); { FileReader input = null; try { input = new FileReader(fname); BufferedReader bufRead = new BufferedReader(input); String line; int count = 0; line = bufRead.readLine(); Integer cases = Integer.parseInt(line); count++; while (line != null) { if (count == 1) { line = bufRead.readLine(); count++; continue; } Map<String, String> params = new HashMap<String, String>(); params.put("str", line); line = bufRead.readLine(); casesList.add(params); count++; } bufRead.close(); } catch (FileNotFoundException ex) { Logger.getLogger(Jam_B.class.getName()).log(Level.SEVERE, null, ex); }catch (ArrayIndexOutOfBoundsException e){ System.out.println("Usage: java ReadFile filename\n"); }catch (IOException e){ System.out.println(e.getMessage()); } finally { try { input.close(); } catch (IOException ex) { Logger.getLogger(Jam_B.class.getName()).log(Level.SEVERE, null, ex); } } } return casesList; } }
0
39
A12852
A10357
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class B { public static void main(String[] args) throws IOException { int nCases; String filename="B-small-attempt0"; //String filename="TestB"; Scanner reader = new Scanner (new FileReader(filename + ".in")); PrintWriter writer = new PrintWriter(new FileWriter(filename + ".out")); nCases = reader.nextInt(); for (int i=0; i<nCases; i++){ writer.print("Case #" + (i+1)+": "); int nDancers= reader.nextInt(); int S = reader.nextInt(); int p = reader.nextInt(); int out = 0; //output for (int j=0;j<nDancers;j++){ int temp = reader.nextInt(); if (temp > 3*p-3) out++; else if (S>0 && (temp == 3*p-3 || temp == 3*p-4) && p!=1){ out ++; S--; } } writer.println(out); } writer.flush(); } }
0
40
A12852
A10244
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
/* * Gabriel Shaw * 4/13/12 */ import java.io.File; import java.io.PrintWriter; import java.io.IOException; import java.util.Scanner; public class DancingWithTheGooglers { public static void main(String[] args) throws IOException { File file = new File("B-small-attempt1.in"); PrintWriter outfile = new PrintWriter("B-small.out"); Scanner infile = new Scanner(file); int numberOfCases; int numberOfGooglers; int desiredScore; int numberOfSuprisingCases; int numberOfGoodScores; numberOfCases = infile.nextInt(); infile.nextLine(); for(int i=0 ; i<numberOfCases ; i++) { numberOfGooglers = infile.nextInt(); numberOfSuprisingCases = infile.nextInt(); desiredScore = infile.nextInt(); numberOfGoodScores = 0; for(int j=0 ; j<numberOfGooglers ; j++) { int totalScore = infile.nextInt(); System.out.println(j +" " +(totalScore - desiredScore - (desiredScore - 1) - (desiredScore - 1))); if(desiredScore <= 1) { if(desiredScore == 1) { if(totalScore - desiredScore >= 0) { numberOfGoodScores++; }//end of if(totalScore - desiredScore >= 0) }//end of if(desiredScore == 1) if(desiredScore == 0) { if(totalScore >= 0) { numberOfGoodScores++; } } } if(!(desiredScore <= 1) && (totalScore - desiredScore - (desiredScore - 1) - (desiredScore - 1)) >= 0) { numberOfGoodScores++; }else { if(!(desiredScore <= 1) && (numberOfSuprisingCases > 0) && (totalScore -desiredScore - (desiredScore - 2) - (desiredScore - 2)) >= 0) { numberOfGoodScores++; numberOfSuprisingCases--; }//end of if((numberOfSuprisingCases > 0) && (totalScore -desiredScore - 2*(desiredScore - 2)) >= 0) }//end of else }//end of for(int j=0 ; j<numberOfGooglers ; j++) outfile.println("Case #" +(i+1) +": " +numberOfGoodScores); if(infile.hasNext()) { infile.nextLine(); } }//end of for(int i=0 ; i<numberOfCases ; i++) outfile.close(); }//end of public static void main(String[] args) throws IOException }//end of public class DancingWithTheGooglers
0
41
A12852
A11913
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class B { public static void main(String[] args) throws IOException { // Scanner in = new Scanner(new File("in/B/test.in")); Scanner in = new Scanner(new File("in/B/small.in")); // Scanner in = new Scanner(new File("in/B/big.in")); // BufferedWriter bw = new BufferedWriter(new FileWriter( // "out/B/test.out")); BufferedWriter bw = new BufferedWriter(new FileWriter( "out/B/small.out")); // BufferedWriter bw = new BufferedWriter(new FileWriter( // "out/B/big.out")); int cases = in.nextInt(); for(int c = 1; c <= cases; c++){ int competitors = in.nextInt(); int surprises = in.nextInt(); int minNote = in.nextInt(); int winners = 0; for(int i = 0; i < competitors; i++){ int max = 0, normal = 0; int note = in.nextInt(); System.err.println(note); if(note == 0){ max = 0; normal = 0; }else if(note == 1){ max = 1; normal = 1; }else if(note > 27){ max = 10; normal = 10; }else{ int mod = note%3; max = note/3 + (mod==0?1:mod); normal = max - (mod!=1?1:0); } if(normal >= minNote){ winners++; continue; } if(max == minNote && surprises > 0){ surprises--; winners++; continue; } } bw.write("Case #" + (c) + ": "+winners); System.err.println("Case #" + (c) + ": "+winners); bw.newLine(); } in.close(); bw.flush(); bw.close(); } }
0
42
A12852
A11471
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class DancingWithTheGooglers { private PrintWriter out; private Scanner in; private void init() { } private void solve() { int N = in.nextInt(); int S = in.nextInt(); int p = in.nextInt(); int r = 0; for (int i = 0; i < N; i++) { int best = in.nextInt(); int part = best / 3; int rest = best - part * 3; // rest = 0,1,2 part=4 // 0: 4 4 4->4 3 5; 4 (+1) // 1: 4 4 5->3 5 5; 5 (0) // 2: 4 5 5->4 4 6; 5 (+1) // part=0: +0 // 0: 0 0 0->0 0 0; 0 (+0) // 1: 0 0 1->0 0 1; 1 (+0) // 2: 0 1 1->0 0 2; 1 (+1) // part=1: +0 // 0: 1 1 1->1 0 2; 1 (+1) // 1: 1 1 2->1 1 2; 2 (+0) // 2: 1 2 2->1 1 3; 2 (+1) int max = part + (rest == 0 ? 0 : 1); int add = rest == 1 ? 0 : 1; if (part == 0) { add = rest == 2 ? 1 : 0; } if (S >= 1 && add == 1 && max + 1 == p) { S--; max += add; } if (max >= p) { r++; } } out.println(r); } private void runTests() { init(); int T = Integer.parseInt(in.nextLine()); for (int i = 0; i < T; i++) { out.print("Case #" + (i + 1) + ": "); solve(); } } private void run() { try { runTests(); } finally { close(); } } private void close() { out.close(); in.close(); } public DancingWithTheGooglers() throws FileNotFoundException { this.in = new Scanner(new File("B-small-attempt2.in")); this.out = new PrintWriter(new File("B-small-attempt2.out")); } public static void main(String[] args) throws FileNotFoundException { new DancingWithTheGooglers().run(); } }
0
43
A12852
A11297
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package codejam; public class Triplet { private int total; private int mod3; private int div3; private int maxNormal; private int maxSurprise; public Triplet(int totalPoints) { init(totalPoints); } private void init(int totalPoints) { total = totalPoints; mod3 = total % 3; div3 = total / 3; maxNormal = calcMaxNormal(); maxSurprise = calcMaxSurprise(); } public int calcMaxSurprise() { if ( total == 0 ) return 0; return (mod3 == 2) ? div3 + 2 : div3 + 1; } public int calcMaxNormal() { if ( total == 0 ) return 0; return (mod3 == 0) ? div3 : div3 + 1; } public int getMaxNormal() { return maxNormal; } public int getMaxSurprise() { return maxSurprise; } public static void main(String[] args){ System.out.println("Testing Triplet"); for ( int i=0; i<6; i++ ) { Triplet t = new Triplet(i); System.out.println(i+" n:"+t.calcMaxNormal() + " s:" + t.calcMaxSurprise()); } } }
0
44
A12852
A12406
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); OutputBuilder output = new OutputBuilder(); int tests = s.nextInt(); s.nextLine(); for (int i = 0; i < tests; i++) { output.addLine(String.valueOf(getMaxDancers(s.nextLine()))); } System.out.println(output.toString()); } private static int getMaxDancers(String line) { String[] parameters = line.split(" "); int surprising = Integer.parseInt(parameters[1]); int minScore = Integer.parseInt(parameters[2]); int minNorm = minScore * 3 - 2; int minSurp = minNorm - 2; int dancers = 0; for(int i = 3; i < parameters.length; i++){ int sum = Integer.parseInt(parameters[i]); if(sum >= minNorm || (sum > 1 && sum >= minSurp && surprising-- > 0)){ dancers++; } } return dancers; } private static class OutputBuilder{ private final StringBuilder output = new StringBuilder(); private int i = 1; void addLine(String s){ this.output.append("Case #"); this.output.append(this.i); this.output.append(": "); this.output.append(s); this.output.append("\n"); this.i++; } @Override public String toString(){ return this.output.toString(); } } }
0
45
A12852
A12838
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package jpt.codejam; import java.io.PrintStream; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Codejam2012 { static void solve_Qual_B() throws Exception { Scanner in = new Scanner(System.in); PrintStream out = System.out; int cases = in.nextInt(); for (int nCase = 1; nCase <= cases; ++nCase) { int N = in.nextInt(); int S = in.nextInt(); int p = in.nextInt(); int res = 0; for (int i=0; i<N; ++i) { int t = in.nextInt(); int max1 = (t+2)/3; int max2 = (t+4)/3; if (t<=1 || t>=29) max2 = -1; if (max1 >= p) ++res; else if (max2 >= p && S > 0) { ++res; --S; } } out.printf("Case #%d: %d\n", nCase, res); } } static void solve_Qual_C() throws Exception { Scanner in = new Scanner(System.in); PrintStream out = System.out; int[] ten = new int[8]; ten[0] = 1; for (int i=1; i<ten.length; ++i) ten[i] = ten[i-1]*10; int cases = in.nextInt(); for (int nCase = 1; nCase <= cases; ++nCase) { int A = in.nextInt(); int B = in.nextInt(); int res = 0; Set<Integer> ms = new HashSet<Integer>(); for (int n=A; n<=B; ++n) { int d = 1; for (int aux=10; aux<=n; aux*=10) ++d; ms.clear(); for (int k=1; k<d; ++k) { int q = n % ten[k]; if (q<ten[k-1]) continue; int p = n / ten[k]; int m = q * ten[d-k] + p; if (A<=m && B>=m && n!=m && !ms.contains(m)) ++res; ms.add(m); } } out.printf("Case #%d: %d\n", nCase, res/2); } } public static void main(String[] args) throws Exception { solve_Qual_B(); //solve_Qual_C(); //solve_1A_A(); //solve_1A_B(); //solve_1A_C(); } }
0
46
A12852
A11897
package com.techy.rajeev; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class DancingGame2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new FileReader("techyrajeev.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("myoutput.out")); int num=Integer.valueOf(in.readLine().trim()); int count = 0, l = 1; while (num > 0) { int arrtemp[]=toIntArray(in.readLine()); int N = arrtemp[0]; int S = arrtemp[1]; int p=arrtemp[2]; for(int i=3;i<arrtemp.length;i++){ int base=arrtemp[i]/3; switch(arrtemp[i]%3){ case 0:{ if(base>=p){ count++; }else{ if(S>0 && base>0 && base+1>=p){ count++; S--; } } }break; case 1:{ if(base>=p || base+1>=p){ count++; }else{ if(S>0 && base+1>=p){ count++; S--; } } }break; case 2:{ if(base+1>=p || base>=p){ count++; }else{ if(S>0 && base+2>=p){ count++; S--; } } }break; } } num--; System.out.println("Case #"+l+": "+count); bw.write("Case #"+l+": "+count); bw.newLine(); count=0; l++; } in.close(); bw.close(); } public static int[] toIntArray(String line){ String[] p = line.trim().split("\\s+"); int[] out = new int[p.length]; for(int i=0;i<out.length;i++) out[i] = Integer.valueOf(p[i]); return out; } }
package com.google.codejam.util; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class CodeJamOutputFile extends File { /** * */ private static final long serialVersionUID = -6971460798309687528L; private FileWriter writer; private Boolean caseZero = false; public CodeJamOutputFile(String pathname) { super(pathname); try { this.setWriter(); } catch (IOException e) { } } private void setWriter() throws IOException { this.writer = new FileWriter(this); } public FileWriter getWriter() { return writer; } public void writeCase(int caseId, String result){ if(caseId == 0){ caseZero = true; } caseId = caseZero ? caseId + 1 : caseId; try { writer.write("Case #"+(caseId) +": " + result + "\n"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void close(){ try { writer.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
0
47

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
0
Add dataset card