/* Tanzila Islam Southeast University mail : tanzilamohita@gmail.com Problem Link: https://algo.codemarshal.org/contests/DRP2015/problems/G */ #include<iostream> #include<algorithm> #include<cstdio> using namespace std; int main(){ pair<int,int>pii[51]; int n, t; long long int tot,ans; //long long int tot; cin >> t; for (int z=1; z<=t; z++) { cin >> n; for(int i=0;i<n;i++) cin >> pii[i].second >> pii[i].first; sort(pii, pii+n); tot = 0; for(int i= 0; i < n;i++) tot+=pii[i].second; ans = tot * pii[0].first; for (int i=1; i <n;i++){ tot-=pii[i-1].second; ans = max(ans,tot*pii[i].first); } //cout << "Case "ans << endl; printf("Case %d: %llu\n", z, ans); } return 0; }
Monday, 2 November 2015
G. Geek Power Inc._Solution
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment