Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code Jam Example
#!/usr/bin/php -q
<?php
$handle = @fopen("B-large-practice.in", "r");
$count = fgets($handle);
for( $i = 1; $i <= $count; $i++ ) {
echo 'Case #' . $i . ': ' . implode(' ', array_reverse(explode(' ', trim(fgets($handle)))) ) . PHP_EOL;
}
#!/usr/bin/php -q
<?php
$handle = @fopen("A-large-practice.in", "r");
$count = fgets($handle);
for( $i = 1; $i <= $count; $i++ ) {
$c = fgets($handle);
fgets($handle);
$prods = explode( ' ', fgets($handle) );
$x = 0;
foreach( $prods as $prod ) {
$find = $c - $prod;
if( $find > 0 ) {
if( ( $j = array_search( $find, $prods ) ) !== false && $j != $x ) {
echo 'Case #' . $i . ': ' . (min($x,$j) + 1) . ' ' . (max($x,$j) + 1) . PHP_EOL;
break 1;
}
}
$x++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment