제출 #982990

#제출 시각아이디문제언어결과실행 시간메모리
982990NeroZeinSki 2 (JOI24_ski2)C++17
5 / 100
1 ms348 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<pair<int, int>> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; } long long ans = 0; sort(a.begin(), a.end()); for (int i = 1; i < n; ++i) { if (a[i].first == a[0].first) { ans += k; a[i].first++; } } int available = 1; int mn = a[0].second; for (int i = 1; i < n; ++i) { int j = i; int mn2 = a[i].second; while (j + 1 < n && a[j + 1].first == a[j].first) { j++; mn2 = min(mn2, a[j].second); } int cnt = j - i + 1; ans += max(0, cnt - available) * mn; available = max(0, available - cnt); available += cnt; i = j; mn = min(mn, mn2); } cout << ans << '\n'; 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...