# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110196 | vjudge1 | Ski 2 (JOI24_ski2) | C++17 | 1 ms | 336 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;
int n,k;
pair<int,int>a[500];
vector<int>g;
int lma=0;
int mn;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen("c.INP","r")){
freopen("c.INP","r",stdin);
freopen("c.OUT","w",stdout);
}
cin >>n>>k;
int asw=0;
for(int i=1;i<=n;i++){
cin >>a[i].first>>a[i].second;
}
sort(a+1,a+n+1);
int mn=a[1].second;
int i=2;
lma=1;
for(;i<=n;i++){
if(a[i].first==a[1].first){
asw+=k;
if(!lma)asw+=a[1].second;
else lma--;
}
else break;
}
for(;i<=n;i++){
if(a[i].first!=a[i-1].first){
for(auto o:g){
mn=min(mn,o);
lma++;
}
g.clear();
}
if(!lma)asw+=mn;
else lma--;
g.push_back(a[i].second);
}
cout <<asw;
}
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... |