제출 #1036334

#제출 시각아이디문제언어결과실행 시간메모리
1036334UnforgettableplSki 2 (JOI24_ski2)C++17
12 / 100
1 ms452 KiB
#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<int> cnt(1002); int ans = 0; int minh,minc;cin>>minh>>minc; for(int i=2;i<=n;i++){ int h,c; cin >> h >> c; if(h==minh){ ans+=k; h++; } cnt[h]++; } auto solve = [&](int x){ for(int i=minh+1;i<=1000;i++){ int temp = max(0ll,cnt[i]-x); cnt[i]-=temp; cnt[i+1]+=temp; ans+=k*temp; } }; int actans = INT64_MAX; for(int i=300;i>=0;i--){ solve(i); actans = min(actans,ans+max(0ll,minc*(i-1))); } cout << actans << '\n'; }
#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...