【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

模拟题、用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的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【76.83%】【codeforces 554A】Kyoya and Photobooks

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  4. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  5. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  6. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  7. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  8. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  9. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

随机推荐

  1. JS浮点数精度运算

    一般来讲,我们在项目中必不可少的需要进行各种数值的计算,但是这种计算全部放在服务端会给服务器带来很大的压力,所以势必要客户端来 分担一些计算的压力. 从客户端来说,JavaScript是一门弱类型语言 ...

  2. Win10出现键盘未失灵,按下的键都是快捷键的问题

    某一天,WIN10开机.然后键盘莫名其妙的都无法正常使用,没有卡Window键,键盘也没有失灵,按下的键都成为了快捷键:终于在   https://zhidao.baidu.com/question/ ...

  3. [Swift]Set(集)转换为Array(数组)

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. lodop 打印

    使用Lodop打印: 一.在官网下载http://www.lodop.net/download.html 若是安装还是提示未安装,就按转这个 二.准备两个js 三.需要在页面最上面加入 <htm ...

  5. Windows 使用之那些你还不知道操作

    作者:你未读 整理:君未读 关于使用 win 系统的基本普及. 建议更换 win10 系统 可能很多朋友看到这个建议,心里很不爽,还很不服气,别急,且看官方给出的信息. 也就是说在 2019 年你完全 ...

  6. [C++ 多线程] 学习前瞻

    1 多线程是什么? 1.1 多线程的概念? 说起多线程,那么就不得不说什么是线程,而说起线程,又不得不说什么是进程. 进程可以简单的理解为一个可以独立运行的程序单位,它是线程的集合,进程就是有一个或多 ...

  7. C#时间相关方法

    当前电脑的时间: DateTime.Now//当前时间 DateTime.Now.Date//当前日期的 0:00:00 DateTime.Now.ToLongDateString();//显示日期 ...

  8. 冒泡 [Python]

    冒泡Python class BubbleSort: def __init__(self): self.initArr() def initArr(self): self.arrInfo = [60, ...

  9. linux 怎么用 名字 代替 ip ?

    比如 ssh 1.1.1.1 变成 ssh usr1 在每台机子的/etc/hosts文件中添加ip与名字的对应表

  10. 一次“MySQL server has gone away”故障及其解决

    1,问题现象 某次测试发现,程序失去响应.由于程序集成了EurekaLog组件,弹出了错误框.查看其给出的Call Stack信息,发现没有发生线程死锁(DeadLock=0;),问题在于 Wait ...