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 int long long typedef long long ll; typedef unsigned long long ull; typedef pair<int,int>pii; const int N = 2e5 + 10; const int M = 2e5 + 10; const int inf = 0x3f3f3f3f; const int mod = 998244353;
int n, m; int ans[N]; int h[N],w[N]; int l[N],r[N];
bool cmp(pii d,pii e){ return d.first>e.first; } signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int t; t=1; while (t--) { cin>>n; int s=0; for(int i=1;i<=n;i++){cin>>w[i]>>h[i]; s+=w[i]; l[i]=max(h[i],l[i-1]); } for(int i=n;i>=1;i--)r[i]=max(h[i],r[i+1]);
for(int i=1;i<=n;i++){ int ans=max(l[i-1],r[i+1]); cout<<(ll)ans*(s-w[i])<<" "; } } return 0; }
|