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
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 1000100;
long long dp[2][N];
long long a[N], b[N];
pair<ll,ll> t[N];

int main() {
	int n;
	scanf("%d", &n);
	FOR(i,n) scanf("%lld%lld", &t[i].fi, &t[i].se);
	sort(t,t+n);
	FOR(i,n) a[i] = t[i].fi, b[i] = t[i].se;
	FOR(p,n) {
		FOR(l,n) {
			if (p==0) dp[1][l] = b[l];
			else if (l==0) dp[1][l] = 0;
			else dp[1][l] = max(dp[0][l-1], dp[1][l-1]-(b[l-1]+a[l-1]*p)) + b[l]+a[l]*p;
		}
		long long mx=0;
		FOR(l,n) {
			dp[0][l] = dp[1][l];
			mx = max(mx, dp[1][l]);
		}
		printf("%lld\n", mx);
	}
	return 0;
}