Submission #222121

# Submission time Handle Problem Language Result Execution time Memory
222121 2020-04-12T07:06:24 Z Vimmer Kisik (COCI19_kisik) C++14
0 / 90
275 ms 17784 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define MOD ll(998244353)

using namespace std;

typedef long long ll;

typedef long double ld;


int main()
{

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k;

    cin >> n >> k;

    pair <ll, ll> a[n];

    for (int i = 0; i < n; i++) cin >> a[i].S >> a[i].F;

    sort(a, a + n);

    ll sum = 0, mx = 0, ans = 1e18;

    for (int i = 0; i < n; i++) swap(a[i].F, a[i].S);

    set <pair <ll, int> > se; se.clear();

    for (int i = 0; i < k; i++) {sum += a[i].F; mx = a[i].S; se.insert({a[i].F, i}); }

    ans = sum * mx;

    for (int i = k; i < n; i++)
    {
        if ((*se.rbegin()).F >= a[i].F) continue;

        pair <ll, int> nm = *se.rbegin();

        se.erase(nm);

        ll len = sum + a[i].F - nm.F;

        ll hg = a[i].S;

        sum = len; mx = hg; se.insert({a[i].F, i});

        ans = min(ans, sum * mx);
    }

    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 15608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 16944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 275 ms 17784 KB Output isn't correct
2 Halted 0 ms 0 KB -