Submission #1110206

#TimeUsernameProblemLanguageResultExecution timeMemory
1110206vjudge1Ski 2 (JOI24_ski2)C++17
5 / 100
1 ms2384 KiB
#include<bits/stdc++.h> #define fi first #define se second #define ll long long #define pb push_back using namespace std; ll n,k,h[100005],c[100005],ans,sl; pair<int,int> p[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); // freopen(".INP","r",stdin); // freopen(".OUT","w",stdout); cin>>n>>k; for(int i=1;i<=n;i++) { cin>>h[i]>>c[i]; p[i]={h[i],c[i]}; } sort(p+1,p+1+n); for(int i=2;i<=n;i++) { if(p[1].fi==p[i].fi) { p[i].fi++; ans+=k; } else break; } int mn=p[1].se; sl=1; for(int i=2;i<=n;i++) { int j=i; while(j<=n&&p[i].fi==p[j].fi) { j++; } for(int k=i;k<j;k++) { if(sl>0) sl--; else ans+=mn; } for(int k=i;k<j;k++) { mn=min(mn,p[k].se); sl++; } i=j-1; } 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...