Submission #921325

# Submission time Handle Problem Language Result Execution time Memory
921325 2024-02-03T17:25:41 Z JoksimKaktus Kisik (COCI19_kisik) C++17
90 / 90
1022 ms 73016 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
void output(bool yes){yes ? cout << "Yes" << "\n" : cout << "No" << "\n";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    vector <pair<ll,ll>> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i].second >> v[i].first;
    }
    std::sort(v.begin(), v.end());
    multiset <ll> ml;
    ll sum = 0;
    for(int i = 0;i < k;i++){
        ml.insert(v[i].second);
        sum += v[i].second;
    }
    ll res = sum * v[k-1].first;
    auto it = ml.end();
    it--;
    for(int i = k;i < n;i++){
        if(v[i].second < *it){
            sum = sum + v[i].second - *it;
            ml.insert(v[i].second);
            it--;
            res = min(res,sum * v[i].first);
        }
    }
    cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 9296 KB Output is correct
2 Correct 398 ms 43348 KB Output is correct
3 Correct 560 ms 46272 KB Output is correct
4 Correct 449 ms 42608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 26264 KB Output is correct
2 Correct 30 ms 6228 KB Output is correct
3 Correct 78 ms 12004 KB Output is correct
4 Correct 355 ms 36916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 18716 KB Output is correct
2 Correct 121 ms 18456 KB Output is correct
3 Correct 127 ms 20564 KB Output is correct
4 Correct 1022 ms 73016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 22352 KB Output is correct
2 Correct 739 ms 62800 KB Output is correct
3 Correct 155 ms 20396 KB Output is correct
4 Correct 533 ms 51636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 34384 KB Output is correct
2 Correct 522 ms 46004 KB Output is correct
3 Correct 307 ms 35152 KB Output is correct
4 Correct 159 ms 24404 KB Output is correct