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

【题意】

题意

【题解】

模拟题、用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. javascript BOM基本知识

    1.BOM(Bowser Object Model浏览器对象模型) 浏览器创建的对象通常称作文档(Document)对象,它是浏览器使用的众多对象的一部分,浏览器操作的对象结合起来称作浏览器对象模型( ...

  2. KeepAlived的配置

    KeepAlived的相关配置 KeepAlived 配置 参考帮助 man keepalived.conf 配置文件组件部分: top hierachy(层次) global configurati ...

  3. bzoj3450 Easy(概率期望dp)

    3450: Tyvj1952 Easy Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 876  Solved: 648[Submit][Status] ...

  4. [App Store Connect帮助]三、管理 App 和版本(6.3)转让 App:接受 App 转让

    您必须在转让发起的 60 天内接受转让. 必要职能:“帐户持有人”职能.请参见职能权限. 以具有“帐户持有人”职能用户的身份登录至 App Store Connect. 系统会显示一条通知,指示 Ap ...

  5. LOJ#120. 持久化序列(FHQ Treap)

    题面 传送门 题解 可持久化\(Treap\)搞一搞 //minamoto #include<bits/stdc++.h> #define R register #define inlin ...

  6. Visual Studio Code 扩展工具集,记录

    编码 提高效率及校验 Auto Close Tag 自动闭合标签 Auto Rename Tag 自动更改HTML/XML标签,不需要再进行二次修改,减少50%的工作量! Path Intellise ...

  7. 2、ipconfig命令

    该命令能够显示出正在使用的计算机的IP信息情况.这些信息包括IP地址.子网掩码.默认网关(连接本地计算机与Internet的计算机).通过IP地址可以进行扫描.远程管理.入侵检测等.ipconfig命 ...

  8. 【URL重写】IIS7配置URL重写

    URL Rewrite Module   此模块适用于IIS7.7.5.8. 微软在IIS7中添加了URL的重写模块,并且免费使用,可以导入.htaccess规则,但需要安装. 第一步:安装URL2. ...

  9. java简单打印金字塔(案例)

    学习编程语言,打印简单的金字塔是基础的案例,在这里就简单的写了个案例,希望能帮助到各位 代码 效果 class  kinTa{    public static void main(String[] ...

  10. CF842C Ilya And The Tree

    思路: 1. 如果根节点是0,那么可以通过一次dfs计算出所有节点的最大值. 2. 如果根节点不是0,那么其余各点的最大值一定是根节点的一个因子.首先计算出根节点的所有因子.在dfs到一个深度为d的节 ...