백준 2170 답1 백준 2170 C++ https://www.acmicpc.net/problem/2170 처음엔 당연히 배열을 생각했지만 너무 범위가 넓어서 시간 복잡도가 너무 높아진다.결국 pair sort를 해서 문제를 풀었다.pair를 sort하면 frist가 작은거 순으로 나열되기 성질을 이용하여 문제를 풀었다. #include using namespace std;typedef long long ll;int n; //선의 개수ll result;vector> v;int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; ll x, y; int v_index = 0; for (int i = 0; i > x >> y; v.push_back({ x, y }); }.. 2024. 6. 22. 이전 1 다음