# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110226 | vjudge1 | Ski 2 (JOI24_ski2) | C++17 | 1 ms | 592 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 ff(i, a, b) for(auto i=(a); i<=(b); ++i)
#define ffr(i, b, a) for(auto i=(b); i>=(a); --i)
#define nl "\n"
#define ss " "
#define pb emplace_back
#define fi first
#define se second
#define sz(s) (int)s.size()
#define ms(a,x) memset(a, x, sizeof (a))
#define re exit(0)
#define cn continue
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const int mod=1e9+7;
//const int mod=998244353;
const int maxn=1e5+105;
const int maxm=4*maxn+5;
const ll inf=1e18;
mt19937 ran(time(0));
mt19937_64 ran64(time(0));
void rf(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if(fopen("o.inp","r")){
freopen("o.inp","r",stdin); freopen("o.out","w",stdout);
}
}
void add(int &x, int y)
{
x+=y;
if(x>=mod) x-=mod;
if(x<0) x+=mod;
}
ll n, k;
pll p[maxn];
signed main()
{
rf();
cin>>n>>k;
ff(i, 1, n) cin>>p[i].fi>>p[i].se;
sort(p+1, p+n+1);
ll ans=0, sl=1;
ff(i, 2, n)
{
if(p[i].fi==p[1].fi) ++p[i].fi, ans+=k;
else break;
}
ll mn=p[1].se;
ff(i, 2, n)
{
int j=i;
while(j<=n && p[i].fi==p[j].fi) ++j;
ff(k, i, j-1)
{
if(sl>0) --sl;
else ans+=mn;
}
ff(k, i, j-1)
{
mn=min(mn, p[k].se);
++sl;
}
i=j-1;
}
cout<<ans;
re;
}
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... |