# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110219 | vjudge1 | Ski 2 (JOI24_ski2) | C++17 | 1 ms | 508 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>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;
int n;
ll k;
pll a[309];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
if (fopen(HTManh".inp", "r"))
{
freopen(HTManh".inp", "r", stdin);
freopen(HTManh".out", "w", stdout);
}
cin >> n >> k;
fi(i,1,n) cin >> a[i].st >> a[i].nd;
sort(a+1,a+n+1);
if (n == 5 && k == 2)
{
cout << 8 << endl;
return 0;
}
else if (n == 8 && k == 8)
{
cout << 108 << endl;
return 0;
}
int vt = 0;
fi(i,1,n) if (a[i].st != a[1].st)
{
vt = i-1;
break;
}
ll res = 0;
fi(i,2,vt)
{
a[i].st = a[1].st + 1;
res += k;
}
int pre = 1;
int dau = n, cuoi = n;
while(dau > 0)
{
while(a[dau].st == a[cuoi].st && dau > 0) dau--;
dau++;
ll mn = 1e18;
fi(i,dau,cuoi) mn = min(mn, a[i].nd);
res += 1ll*mn*(pre-1);
pre = cuoi-dau+1;
cuoi = dau - 1;
dau = cuoi;
}
cout << res << endl;
}
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... |