Pagini recente » Cod sursa (job #129281) | Cod sursa (job #1592958) | Cod sursa (job #1858703) | Cod sursa (job #2415768) | Cod sursa (job #1085692)
#include <cstdio>
#include <algorithm>
#define x first
#define y second
#define NMAX 30007
#define LL long long
using namespace std;
pair< int, int > a[NMAX];
LL Sum[NMAX], s;
int n;
int main(){
freopen("bilute.in", "r", stdin);
freopen("bilute.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
scanf("%d %d", &a[i].x, &a[i].y);
Sum[i] = (LL)Sum[i - 1] + (LL)a[i].x;
s += (LL)a[i].x * (LL)a[i].y + (LL)(i - 1) * (LL)a[i].x;
}
pair< LL, int> Ans;
Ans.x = 100000000000000;
for(int i = 1; i <= n; ++i){
if(Ans.x > s - a[i].x * a[i].y){
Ans.x = s - a[i].x * a[i].y;
Ans.y = i;
}
s += Sum[i] - (Sum[n] - Sum[i]);
}
printf("%d %lld", Ans.y, Ans.x);
return 0;
}