1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;

#define MAXN 1000001
#define int long long int
#define pb push_back
#define a first
#define b second
int n;
vector <pair <int,int> > kraw;
pair <int,int> lines[MAXN];
void wczytaj()
{
	scanf("%lld",&n);
	for(int i = 0;i < n;++i)
		scanf("%lld%lld",&lines[i].a,&lines[i].b);
	
}
void __count()
{
	for(int k = 0;k < n;++k)
	{
		kraw.clear();
		for(int i = 0;i < n;++i) kraw.pb(lines[i]);
		
		int wyn = 0;
		for(int x = k;x >= 0;--x)
		{
			int maksik = -1;
			for(int i = 0;i < (int)kraw.size();++i)
				if(maksik == -1 || kraw[maksik].a * x + kraw[maksik].b < kraw[i].a * x + kraw[i].b)
					maksik = i;
					
			wyn += kraw[maksik].a * x + kraw[maksik].b;
			swap(kraw[maksik],kraw.back());
			kraw.pop_back();
		}
		printf("%lld\n",wyn);
	}
}
#undef int
int main()
{
	#define int long long int
	wczytaj();
	__count();
}