Submission #1110212

#TimeUsernameProblemLanguageResultExecution timeMemory
1110212vjudge1Ski 2 (JOI24_ski2)C++17
0 / 100
1 ms2552 KiB
#include<bits/stdc++.h> #define INF 1e18 #define fi first #define se second #define FOR(i, k, n) for(ll i = k; i <= n; i++) #define FOR1(i, k, n) for(ll i = k; i >= n; i--) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vi vector<int> #define pii pair<int, int> #define vii vector<pii> #define ll long long #define vll vector<ll> #define pll pair<ll, ll> #define re return 0 #define mii map<int, int> #define input "BESIEGE.inp" #define output "BESIEGE.out" #define rf freopen(input, "r", stdin); freopen(output, "w", stdout) #define int ll using namespace std; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; const int base = 998244353; void add(int &a, int b) { a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; } pii a[maxn]; bool vis[maxn]; int b[maxn]; bool cmp(pii x, pii y) { return x.fi > y.fi; } int d[maxn]; multiset<pair<int, pii>> s; signed main() { fastio; int n, k; cin >> n >> k; FOR(i, 1, n) cin >> a[i].fi >> a[i].se; ll ans = 0; FOR(i, 1, n) d[i] = 1; if(n == 1) { cout << 0; re; } sort(a + 1, a + 1 + n); FOR(i, 2, n) if(a[i].fi == a[1].fi) ans += k, a[i].fi++; s.insert({a[2].se, {a[2].fi, 2}}); int dem = 0; FOR(i, 3, n) { bool ok = 0; int id = -1, vtmin = -1; for(auto x : s) { if(x.se.fi < a[i].fi) { if(vtmin == -1) vtmin = x.se.se; ok = 1; int id1 = x.se.se; if(d[id1]) { id = id1; break; } } } if(ok == 0) { dem++; } if(id != -1) { d[id]--; } else { ans += a[vtmin].se; } s.insert({a[i].se, {a[i].fi, i}}); } cout << ans + dem * a[1].se; re; }
#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...