Submission #824177

#TimeUsernameProblemLanguageResultExecution timeMemory
824177Username_taken12Cloud Computing (CEOI18_clo)Java
Compilation error
0 ms0 KiB
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); ArrayList<int[]> t = new ArrayList<>(); int N = Integer.parseInt(r.readLine()); for(int i=0; i<N; i++) { StringTokenizer st = new StringTokenizer(r.readLine()); //cores clockspeed price int[] add = new int[]{Integer.parseInt(st.nextToken()), -1*Integer.parseInt(st.nextToken()), -1*Integer.parseInt(st.nextToken())}; t.add(add); } int M = Integer.parseInt(r.readLine()); for(int i=0; i<M; i++){ StringTokenizer st = new StringTokenizer(r.readLine()); int[] add = new int[]{-1*Integer.parseInt(st.nextToken()), -1*Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())}; t.add(add); } Collections.sort(t, new Comp()); //for(int i=0; i<t.size(); i++) // System.out.println(Arrays.toString(t.get(i))); long[][] dp = new long[N+M+1][2000*50+1]; for(int i=0; i<N+M+1; i++) for(int j=0; j<2000*50+1; j++) dp[i][j]=-100000; dp[0][0]=0; for(int i=0; i<N+M; i++) for(int j=0; j<2000*50+1; j++){ if(dp[i][j]!=-100000&&((t.get(i)[0]+j)>=0)){ dp[i+1][j+t.get(i)[0]]=Math.max(dp[i+1][j+t.get(i)[0]], dp[i][j]+t.get(i)[2]); } dp[i+1][j]=Math.max(dp[i][j], dp[i+1][j]); } /*for(int i=0; i<N+M; i++){ for(int j=0; j<40; j++) System.out.print(dp[i][j]+" "); System.out.println(); }*/ long max=0; for(int j=0; j<2000*50+1; j++) { max=Math.max(dp[N+M][j], max); } pw.println(max); pw.close(); } } class Comp implements Comparator<int[]>{ public int compare(int[] a , int[] b){ return Integer.compare(a[1], b[1]); } }

Compilation message (stderr)

clo.java:4: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error