본문 바로가기

코테 문풀

(6)
[Algorithm] 프로그래머스 - H-Index(level 2) #include #include #include #include #include #define endl '\n' using namespace std; bool cmp(int a, int b){ if(a!=b) return a>b; } int solution(vector citations) { int answer = 0; sort(citations.begin(), citations.end(), cmp); for(int i = 0;icitations[i]) return i; } return citations.size(); }
[Algorithm] BOJ 16235 - 나무 재테크(C++) 해당 문제는 그냥 시뮬레이션 구현 문제이다. #include #include #include #include using namespace std; typedef struct { int yangbun; vector trees; }Map; int n,m,k; int dx[] = {-1, -1, 0 ,1, 1,1, 0,-1}; int dy[] = {0,-1,-1,-1,0,1,1,1}; //좌 상 우 하 int A[11][11]; Map G[11][11]; void initVar(void){ cin >> n >> m >> k; for(int i = 1; i A[i][j]; G[i][j].yangbun = 5; } } for(int i = 0; i> row >> col >> age; G[row][col].tree..
[Algorithm] 프로그래머스 - 신고 결과 받기(level 1) #include #include #include #include #include #define endl '\n' using namespace std; vector solution(vector id_list, vector report, int k) { vector answer; sort(report.begin(), report.end()); report.erase(unique(report.begin(),report.end()),report.end()); vector report_list[id_list.size()]; map mymap; map reporting_list; int id_cnt = id_list.size(); int *report_cnt = new int[id_cnt]; for(int i =0;i
[Algorithm] BOJ 1260 - DFS와 BFS (C++) #include #include #include #include #include using namespace std; typedef long long ll; int N, M, V; typedef struct Node { char idx; bool visited = false; vector vec; // char vec_idx = 0; }Node; vector node_vec; void input(void) { cin >> N >> M >> V; Node tmp; tmp.idx = -1; node_vec.push_back(tmp); for (int i = 1; i > a >> b; node_vec[a].vec.push_back(b); node_vec[b].vec.push_back(a); } for (int..
[BOJ] 12100 - 2048(EASY) #include #include #define endl "\n" #define up 0 #define down 1 #define left 2 #define right 3 using namespace std; int basic_map[21][21]; int n; int max(int** map) { int m = -1; for (int i = 0; i m) m = map[i][j]; } } return m; } int** move(int** map, int dir) { int idx; queue q; if (dir == up) { //cout
[Algorithm] BOJ 11053번 #include #include #include #include using namespace std; typedef long long ll; int *arr; int *memo; int lss(int size) { int min_or_max; int cnt = 0; int answer = 1; for (int i = 0; i arr[j]) mid_result += 1; else continue; if (mid_result > memo[i]) memo[i] = mid_result; } if (memo[i] > answer) answer..