Submission #2553863
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] S = new int[N]; for (int i = 0; i < N; i++) { S[i] = sc.nextInt(); } System.out.println( solve(N, S) ); } private static int solve(int N, int[] S) { boolean[][] dp = new boolean[N + 1][100 + 1]; dp[0][0] = true; for (int i = 1; i <= N; i++) { int s = S[i-1]; for (int p = 0; p <= 100; p++) { if( p >= s ) { dp[i][p] = dp[i-1][p-s] || dp[i-1][p]; } else { dp[i][p] = dp[i-1][p]; } } } int ans = 0; for (int i = 0; i <= 100; i++) { if( dp[N][i] && i % 10 != 0 ) { ans = Math.max(ans, i); } } return ans; } private static void showPoints(boolean[] points) { List<Integer> result = new ArrayList<>(); for (int i = 0; i <= 100; i++) { if( points[i] ) { result.add(i); } } System.err.println( result ); } }
Submission Info
Submission Time | |
---|---|
Task | C - Bugged |
User | kusomushi |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1285 Byte |
Status | WA |
Exec Time | 103 ms |
Memory | 21844 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | a01, a02, a03 |
All | a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a01 | AC | 95 ms | 21716 KB |
a02 | AC | 94 ms | 19028 KB |
a03 | AC | 94 ms | 21844 KB |
b04 | AC | 94 ms | 19796 KB |
b05 | WA | 103 ms | 18644 KB |
b06 | WA | 98 ms | 18636 KB |
b07 | WA | 100 ms | 18644 KB |
b08 | WA | 98 ms | 18640 KB |
b09 | WA | 103 ms | 20816 KB |
b10 | AC | 93 ms | 21844 KB |
b11 | AC | 99 ms | 18900 KB |
b12 | AC | 99 ms | 19924 KB |