목록코테/프로그래머스 (3)
경주장
#include #include #include #define INF 500001 #define MAX(x,y) x>y?x:y using namespace std; vector a[20001]; //edge info int cost[20001]; void dijkstra(int s) { cost[s] = 0; queue pq; pq.push({s,0}); while(!pq.empty()) { int cur = pq.front().first; int dist = -pq.front().second; pq.pop(); if(cost[cur] < dist) continue; for(int i = 0 ; i < a[cur].size(); i++) { int next = a[cur][i]; int nextDist ..
1. my sol #include #include #include #include #include using namespace std; vector done(4500,0); vector l(4500,0); vector sum(4500,0); void proc( map m) { for(auto i : m) { int cnt = 0 ; cnt += i.second.size(); if(done[i.first]!=2) done[i.first] = cnt>0 ? 0 : 1; } } bool empty_all( map inv_map) { bool b = true;; for(auto i : inv_map) { int cnt = 0 ; cnt += i.second.size(); if(cnt>0) b = false; }..
1. my #include #include #include using namespace std; typedef long long ll; ll solution(int n, vector times) { ll answer = 0; int l = times.size(); vector t (l,0); vector p (l,0); sort(times.begin(), times.end()); while(n -- ) { for(int i = 0 ; i < l ; i ++) t[i] += times[i]; int idx = min_element(t.begin(), t.end()) - t.begin(); p[idx] ++; for(int i = 0 ; i < l ; i ++) if(i!=idx) t[i] -= times[..