Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using lli=long long ;
- const lli INF=1e9;
- using pii=pair<lli,lli>;
- int main(){
- int n;
- scanf("%d",&n);
- pii ar[n+1];
- for(int i=1;i<=n;i++){
- lli x,y;
- scanf("%lld %lld",&x,&y);
- ar[i]={y,x};
- }
- sort(ar+1,ar+n+1);
- long long sum=0,fire=0,sum_max;
- double mx=0.0;
- for(int i=1;i<=n;i++){
- sum+=ar[i].second;
- if(sum/(double)ar[i].first>mx) {
- mx=(double)sum/ar[i].first;
- sum_max=sum;
- fire=ar[i].first;
- }
- }
- printf("%lld %lld",sum_max,fire);
- return 0;
- }
- /*
- 5
- 3 30
- 6 10
- 10 20
- 7 50
- 18 70
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement