import java.util.Arrays; import java.util.Scanner; public class Main { public static int MAX = 20000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); House[] h = new House[n]; for(int i=0;iInteger.compare(a.v + a.t, b.v + b.t)); boolean[] dp = new boolean[MAX+1]; dp[0] = true; for(int i=0;i=0;j--) { if (dp[j]) { dp[j+h[i].v] = true; } } } int max = 0; for(int i=0;i<=MAX;i++) { if (dp[i]) { max = i; } } System.out.println(max); } static class House { int v,t; public House(int v,int t) { this.v = v; this.t = t; } } }