【Codeforces 522B】Photo to Remember
【链接】  我是链接,点我呀:) 
 【题意】
题意
【题解】
模拟题、用set模拟下就好
【代码】
import java.io.*;
import java.util.*;
public class Main {
    static InputReader in;
    static PrintWriter out;
    public static void main(String[] args) throws IOException{
        //InputStream ins = new FileInputStream("E:\\rush.txt");
        InputStream ins = System.in;
        in = new InputReader(ins);
        out = new PrintWriter(System.out);
        //code start from here
        new Task().solve(in, out);
        out.close();
    }
    static int N = 200000;
    static class Task{
    	static class cmp implements Comparator<Integer>{
			@Override
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
    	}
        int n;
        int w[] = new int[N+10],h[] = new int[N+10];
        int cnt[] = new int[N+10];
        long sum = 0;
        TreeSet myset = new TreeSet(new cmp());
        public void solve(InputReader in,PrintWriter out) {
        	n = in.nextInt();
        	for (int i = 1;i <= n;i++) {
        		w[i] = in.nextInt();h[i] = in.nextInt();
        		if (myset.contains(h[i])) {
        			cnt[h[i]]++;
        		}else {
        			myset.add(h[i]);
        			cnt[h[i]] = 1;
        		}
        		sum = sum + w[i];
        	}
        	for (int i = 1;i <= n;i++) {
        		long tempsum = sum - w[i];
        		if (cnt[h[i]]==1) {
        			myset.remove(h[i]);
        		}
        		int high = (int)myset.first();
        		out.print(1l*high*tempsum+" ");
        		if (cnt[h[i]]==1) {
        			myset.add(h[i]);
        		}
        	}
        }
    }
    static class InputReader{
        public BufferedReader br;
        public StringTokenizer tokenizer;
        public InputReader(InputStream ins) {
            br = new BufferedReader(new InputStreamReader(ins));
            tokenizer = null;
        }
        public String next(){
            while (tokenizer==null || !tokenizer.hasMoreTokens()) {
                try {
                tokenizer = new StringTokenizer(br.readLine());
                }catch(IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
【Codeforces 522B】Photo to Remember的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
		[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ... 
- 【76.83%】【codeforces 554A】Kyoya and Photobooks
		time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ... 
- 【codeforces 707E】Garlands
		[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ... 
- 【codeforces 707C】Pythagorean Triples
		[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ... 
- 【codeforces 709D】Recover the String
		[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ... 
- 【codeforces 709B】Checkpoints
		[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ... 
- 【codeforces 709C】Letters Cyclic Shift
		[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ... 
- 【Codeforces 429D】 Tricky Function
		[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ... 
- 【Codeforces 670C】 Cinema
		[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ... 
随机推荐
- E20170531-hm
			passage n. 通路; 通道 discrete adj. 分离的,不相关联的; 分立式; 非连续; alternative 替代的; 另类的; 备选的; 其他的; intent ... 
- [App Store Connect帮助]六、测试 Beta 版本(4.3) 管理 Beta 版构建版本:为 Beta 版构建版本提供出口合规证明
			如果您没有完成出口合规证明,则该 Beta 版构建版本的状态为“缺少合规证明”.您可以在 TestFlight 部分中回答必需的出口合规证明问题. 必要职能:“帐户持有人”职能.“管理”职能或“App ... 
- VUE学习之计算属性computed
			计算属性:computed 先看一下官网的说法 模板内的表达式非常便利,但是设计它们的初衷是用于简单运算的.在模板中放入太多的逻辑会让模板过重且难以维护.例如: <div id="ex ... 
- php+ajax+jquery实现jsonp跨域
			我们有这么个html文件test.html: 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ... 
- Mysql动态查询
			if条件查询 格式: <if test=”条件判断”> 添加到sql的语句 </if> where标签 简化SQL语句中WHERE条件判断 智能处理and和or 如果使用几个i ... 
- git初使用的心得
			转到Java方向后,版本控制工具也开始以git为主了.由于之前不怎么使用bash,所以目前还是以ui工具,比如sourcetree为主导,但一些简单的操作命令,已经能够快速地使用.sourcetree ... 
- Selenium示例集锦--常见元素识别方法、下拉框、文本域及富文本框、鼠标操作、一组元素定位、弹窗、多窗口处理、JS、frame、文件上传和下载
			元素定位及其他操作 0.常见的识别元素的方法是什么? driver.find_element_by_id() driver.find_element_by_name() driver.find_ele ... 
- 联想 S5【K520】免解锁BL 免rec 保留数据 Magisk Xposed 救砖 ROOT ZUI 3.7.490
			>>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ... 
- Java反射机制实战——字段篇
			首先,我们来认识几个类. Class(java.lang.Class) Class对象是一个特殊对象,每一个类都有一个Class对象,用来创建该类的“常规”对象.可以通过对象的getClass()方法 ... 
- PostgreSQL 备忘
			truncate table page_frame_mst; select setval('page_frame_mst_id_seq', 1, false): select setval('imag ... 
