CodeForces 522B 手速题
//戳这里:522B
//Problem tags 上竟然有人贴 data structures...保存最大的两个 h[i] 不就好了么......
1 #include "iostream" 2 #include "cstdio" 3 using namespace std; 4 int n, w[200010], h[200010], sw, h1, h1_pos, h2; 5 6 int main() 7 { 8 int i; 9 scanf("%d", &n); 10 for(i = 1; i <= n; ++i) { 11 scanf("%d%d", &w[i], &h[i]); 12 sw += w[i]; 13 if(h1 < h[i]) { 14 h2 = h1; 15 h1 = h[i]; 16 h1_pos = i; 17 } 18 else { 19 if(h2 < h[i]) { 20 h2 = h[i]; 21 } 22 } 23 } 24 for(i = 1; i <= n; ++i) { 25 printf("%d ", (sw - w[i]) * (i == h1_pos? h2: h1)); 26 } 27 }