Submission #313941

# Submission time Handle Problem Language Result Execution time Memory
313941 2020-10-17T11:56:48 Z neki Kisik (COCI19_kisik) C++14
90 / 90
423 ms 23652 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 1100000
#define pa pair<ll, ll>
#define ld long double 
priority_queue<ll> q;
pa arr[mn];
int main(){
    ll n, k;cin >> n>>k;
    loop(i, 0, n) sc("%lld%lld", &arr[i].se, &arr[i].fi);
    sort(arr, arr+n);
    ll cur=0, ans=llmax;
    loop(i, 0, n){
        q.push(arr[i].se);
        cur+=arr[i].se;
        if(q.size()>k) cur-=q.top(), q.pop();
        if(q.size()==k) ans=min(ans, cur * arr[i].fi);
    }
    cout << ans <<endl;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:32:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   32 |         if(q.size()>k) cur-=q.top(), q.pop();
      |            ~~~~~~~~^~
kisik.cpp:33:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   33 |         if(q.size()==k) ans=min(ans, cur * arr[i].fi);
      |            ~~~~~~~~^~~
kisik.cpp:26:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     loop(i, 0, n) sc("%lld%lld", &arr[i].se, &arr[i].fi);
      |                     ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 4984 KB Output is correct
2 Correct 294 ms 14312 KB Output is correct
3 Correct 254 ms 18148 KB Output is correct
4 Correct 226 ms 17288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 9172 KB Output is correct
2 Correct 31 ms 2800 KB Output is correct
3 Correct 63 ms 4972 KB Output is correct
4 Correct 199 ms 12140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 6380 KB Output is correct
2 Correct 243 ms 8952 KB Output is correct
3 Correct 179 ms 7536 KB Output is correct
4 Correct 402 ms 23652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 7404 KB Output is correct
2 Correct 423 ms 18536 KB Output is correct
3 Correct 119 ms 6792 KB Output is correct
4 Correct 275 ms 19300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 11760 KB Output is correct
2 Correct 263 ms 14056 KB Output is correct
3 Correct 213 ms 12008 KB Output is correct
4 Correct 133 ms 9576 KB Output is correct