Submission #100976

# Submission time Handle Problem Language Result Execution time Memory
100976 2019-03-15T15:45:52 Z KLPP Kisik (COCI19_kisik) C++14
90 / 90
501 ms 32360 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  pair<lld,lld> arr[n];
  for(int i=0;i<n;i++){
    scanf("%lld %lld",&arr[i].second,&arr[i].first);
  }
  sort(arr,arr+n);
  priority_queue<int> pq;
  lld sum=0;
  lld ans=1000000000000000000;
  for(int i=0;i<n;i++){
    pq.push(arr[i].second);
    sum+=arr[i].second;
    if(pq.size()>k){
      sum-=pq.top();
      pq.pop();
    }
    if(pq.size()==k){
      ans=min(ans,sum*arr[i].first);
    }
  }cout<<ans<<endl;
	return 0;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:20:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(pq.size()>k){
        ~~~~~~~~~^~
kisik.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(pq.size()==k){
        ~~~~~~~~~^~~
kisik.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&k);
   ~~~~~^~~~~~~~~~~~~~~
kisik.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&arr[i].second,&arr[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 8824 KB Output is correct
2 Correct 300 ms 20592 KB Output is correct
3 Correct 279 ms 22044 KB Output is correct
4 Correct 321 ms 20712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 269 ms 13736 KB Output is correct
2 Correct 33 ms 3188 KB Output is correct
3 Correct 74 ms 5976 KB Output is correct
4 Correct 211 ms 16620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8688 KB Output is correct
2 Correct 227 ms 16104 KB Output is correct
3 Correct 196 ms 12020 KB Output is correct
4 Correct 455 ms 32360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 10480 KB Output is correct
2 Correct 501 ms 28268 KB Output is correct
3 Correct 121 ms 9328 KB Output is correct
4 Correct 333 ms 24176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 311 ms 20076 KB Output is correct
2 Correct 316 ms 20176 KB Output is correct
3 Correct 254 ms 16528 KB Output is correct
4 Correct 155 ms 11816 KB Output is correct