제출 #981975

#제출 시각아이디문제언어결과실행 시간메모리
981975aymanrsSki 2 (JOI24_ski2)C++14
5 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; void solve(){ int n, k;cin >> n >> k; long long ans = 0; pair<int, int> a[n];for(int i = 0;i < n;i++) cin >> a[i].first >> a[i].second; sort(a, a+n); int m=a[0].second, mx = INT_MAX, x = -1, d = 1, dx = 0; for(int i = 1;i < n && a[i].first == a[0].first;i++){ a[i].first++; ans += k; } for(int i = 1;i < n;i++){ if(a[i].first!=x){ d+=dx; x = a[i].first; m = min(m, mx); dx = 1; mx = a[i].second; } else { mx = min(mx, a[i].second); dx++; } if(d) d--; else ans += m; } cout << ans << '\n'; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve(); }
#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...