diff --git a/src/jinu/week21/Week21_18808.java b/src/jinu/week21/Week21_18808.java new file mode 100644 index 0000000..9eb84c4 --- /dev/null +++ b/src/jinu/week21/Week21_18808.java @@ -0,0 +1,160 @@ +package jinu.week21; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +public class Week21_18808 { + + static int noteBook[][]; + + static List stickers; + + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + noteBook = new int[N][M]; + + int K = Integer.parseInt(st.nextToken()); + + stickers = new ArrayList<>(); + + for(int i = 0;i < K; i++){ + st = new StringTokenizer(br.readLine()); + + int R = Integer.parseInt(st.nextToken()); + int C = Integer.parseInt(st.nextToken()); + + int tmp[][] = new int[R][C]; + + for(int r = 0; r= noteBook.length || x >= noteBook[0].length){ + return false; + } + + if(noteBook[y][x]==1 && applySticker[y-i][x-j] == 1){ + return false; + } + } + } + + return true; + } + + public static void apply(int [][]noteBook, int applySticker[][], int i, int j){ + + for(int y = i; y < i + applySticker.length; y++){ + for(int x = j; x < j + applySticker[0].length; x++){ + + if(noteBook[y][x]==0 && applySticker[y-i][x-j]==1){ + noteBook[y][x] = applySticker[y-i][x-j]; + } + } + } + } + + public static int[][] turnRight(int [][]applySticker){ + + int tmpApplySticker[][] = new int[applySticker[0].length][applySticker.length]; + + for(int i = 0; i abilities[]; + + static class Node implements Comparable{ + int index; + int ability; + + public Node(int index, int ability){ + this.index = index; + this.ability = ability; + } + + public int compareTo(Node n){ + return this.ability-n.ability; + } + } + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + abilities = new List[N]; + for(int i =0;i(); + for(int j=0;j pq = new PriorityQueue<>(); + + int max = Integer.MIN_VALUE; + + for(int i=0;i{ + + int height; + int cost; + + public Painting(int height, int cost){ + this.height = height; + this.cost = cost; + } + + @Override + public int compareTo(Painting p){ + return this.height - p.height; + } + } + + static Painting[] paintings; + static int []limit, dp; + static int N,S; + + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + S = Integer.parseInt(st.nextToken()); + + paintings = new Painting[N]; + dp = new int[N]; + limit = new int[N]; + + for(int i=0;i -1){ + dp[i] = Math.max(dp[findMaxHighIndex]+paintings[i].cost, dp[i-1]); + } + else{ + dp[i] = Math.max(dp[i-1], paintings[i].cost); + } + } + + System.out.println(dp[N-1]); + + + + + + } + + static int binarySearch(int index){ + int mid = 0; + int left = 0; + int right = index; + + while(left<=right){ + mid = (left+right)/2; + + int diff = paintings[index].height - paintings[mid].height; + + if(diff>=S){ + left = mid+1; + } + else{ + right = mid - 1; + } + } + + return left - 1; + } + +}