제출 #588592

#제출 시각아이디문제언어결과실행 시간메모리
588592Jomnoi도로 폐쇄 (APIO21_roads)C++17
5 / 100
47 ms5656 KiB
#include <bits/stdc++.h> #include "roads.h" using namespace std; const int MAX_N = 1e5 + 5; int dp[MAX_N]; bool used[MAX_N]; vector <long long> minimum_closure_costs(int N, vector <int> U, vector <int> V, vector <int> W) { bool subtask1 = true, subtask2 = true; for(int i = 0; i < N - 1; i++) { if(U[i] != 0 and V[i] != 0) { subtask1 = false; } if(U[i] != i or V[i] != i + 1) { subtask2 = false; } } vector <long long> ans; if(subtask1 == true) { sort(W.rbegin(), W.rend()); long long sum = 0; for(int i = 0; i < N - 1; i++) { sum += W[i]; } for(int i = 0; i < N - 1; i++) { ans.push_back(sum); sum -= W[i]; } ans.push_back(0); } else if(subtask2 == true) { long long sum = 0; for(int i = 0; i < N - 1; i++) { sum += W[i]; } ans.push_back(sum); for(int i = 0; i < N - 1; i++) { dp[i] = max(dp[i - 1], dp[i - 2] + W[i]); } ans.push_back(sum - dp[N - 2]); for(int i = 0; i < N - 2; i++) { ans.push_back(0); } } else if(N <= 200) { // do something } else if(N <= 2000) { // do something } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...