# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036327 | Unforgettablepl | Ski 2 (JOI24_ski2) | C++17 | 1 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
vector<vector<int>> arr(301);
vector<pair<int,int>> temp;
int offset = 300;
for(int i=1;i<=n;i++){
int h,c;
cin >> h >> c;
offset=min(offset,h);
temp.emplace_back(h,c);
}
for(auto&[h,c]:temp)arr[h-offset].emplace_back(c);
for(int&i:arr[0])if(i<arr[0][0])swap(i,arr[0][0]);
int ans = 0;
for(int i=1;i<arr[0].size();i++){
ans+=k;
arr[1].emplace_back(arr[0][i]);
}
arr[0].resize(1);
int free = 1;
int currmin = arr[0][0];
for(int i=1;i<=300;i++){
for(int&x:arr[i]){
if(free)free--;
else ans+=currmin;
}
for(int&x:arr[i]){
free++;
currmin=min(currmin,x);
}
}
cout << ans << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |