160 problems solved
Rank by points: #2662
Total points:
213
1 contest written
Rank by rating: #2293
Rating: 1378
Min. rating: 1378
Max rating: 1378
From Thornlea S.S., Olympiads School
About
The solution to CCC '17 S3 - Nailed It!, in case anyone is interested, is as follows (confirmed to pass test cases):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Nailed_It {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String args[]) throws IOException {
int n = Integer.parseInt(br.readLine());
String tokens[] = br.readLine().split(" ");
int woodlen[] = new int[4001], boardlen[] = new int[4001];
for(int i = 0; i < n; i++)
woodlen[Integer.parseInt(tokens[i])]++;
for(int i = 2; i < 4001; i++) {
for(int j = 1; j <= i / 2; j++) {
if(j == i - j)
boardlen[i] += woodlen[j] / 2;
else
boardlen[i] += Math.min(woodlen[j], woodlen[i - j]);
}
}
int maxlen = Integer.MIN_VALUE, numways = 0;
for(int i = 2; i < 4001; i++) {
if(boardlen[i] > maxlen) {
maxlen = boardlen[i];
numways = 1;
} else if(boardlen[i] == maxlen)
numways++;
}
System.out.print(maxlen + " " + numways);
}
}
Rating history
, #