제출 #1181304

#제출 시각아이디문제언어결과실행 시간메모리
1181304trashaccountSki 2 (JOI24_ski2)C++20
0 / 100
45 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int NM = 300, inf = 1e18; int N, K, H[NM+5], C[NM+5], tmpH[NM+5], tmpC[NM+5]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for (int i = 1; i <= N; i++) cin >> H[i] >> C[i]; int ans = +inf; for (int i = 1; i <= N; i++){ int res = 0; for (int j = 1; j <= N; j++){ tmpC[j] = 0; if (j == i){ tmpH[j] = H[j]; continue; } tmpH[j] = max(H[i]+1, H[j]); res += (tmpH[j]-H[j])*K; } for (int j = 1; j <= N; j++){ int kbest = -1; for (int k = 1; k <= N; k++) if (tmpH[k] < tmpH[j]){ if (kbest == -1 || (tmpC[k] < tmpC[kbest] || (tmpC[k] == tmpC[kbest] && tmpH[k] > tmpH[kbest]))) kbest = k; } if (kbest != -1){ res += tmpC[kbest]; if (tmpC[kbest] == 0) tmpC[kbest] = C[kbest]; } } ans = min(ans, res); } cout << ans; return 0; }
#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...