답안 #313940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313940 2020-10-17T11:55:57 Z neki Kisik (COCI19_kisik) C++14
40 / 90
104 ms 6380 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 260000
#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);
      |                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 78 ms 4396 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 78 ms 4344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 6380 KB Output is correct
2 Execution timed out 73 ms 4400 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 77 ms 4344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 95 ms 4404 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -