백준 22341 사각형 면적
#include #define LM 1000+10 #define INF 199999999 using LL = long long; using namespace std; int N,C; int X,Y; int A,B; int Dx[] = {0,1,0,-1,1,1,-1,-1},Dy[] = {1,0,-1,0,1,-1,1,-1}; void paper(){ if(A
2021. 7. 28.
백준 11286 절댓값 힙
algorithm : priority_queue 해설 priority_queue 경우 가장 큰 수부터 출력하는 성질이 있다. 그렇기 때문에 queue에 넣을 때랑 뺄 때 * (-1) 해서 음수로 만든다. 이런 식으로 면 최솟값부터 priority_queue를 뺄 수 있다. pair first에는 x를 절댓값을 한 것, second는 원래 x값 #include #define LM 1000+10 #define INF 199999999 using LL = long long; using namespace std; int N; int x; priority_queue pq; int Dx[] = {0,1,0,-1,1,1,-1,-1},Dy[] = {1,0,-1,0,1,-1,1,-1}; void input(){ scan..
2021. 7. 18.
백준 2631 줄세우기
algorithm : DP,LIS 해설 3 7 5 2 6 1 4 이 경우 4번만 교환하면 된다 왜냐하면 3,5,6은 순서를 바꾸지 않아도 되기 때문에 전체 길이에서 배열에서 가장 긴 증가하는 수열(LIS)를 빼면 구할수 있다. #include #define LM 1000+10 #define INF 199999999 using LL = long long; using namespace std; int N; int arr[LM]; int dp[LM]; int ans; int Dx[] = {0,1,0,-1,1,1,-1,-1},Dy[] = {1,0,-1,0,1,-1,1,-1}; void input(){ scanf("%d",&N); for(int i = 1 ; i
2021. 7. 16.