/*

Problem Statement

Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her Ti seconds to solve problem i(1≦iN).

Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦iM), her brain will be stimulated and the time it takes for her to solve problem Pi will become Xi seconds. It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Constraints

  • All input values are integers.
  • 1≦N≦100
  • 1≦Ti≦105
  • 1≦M≦100
  • 1≦PiN
  • 1≦Xi≦105

Input

The input is given from Standard Input in the following format:

  1. N
  2. T1 T2 TN
  3. M
  4. P1 X1
  5. P2 X2
  6. :
  7. PM XM

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

Sample Input 1

  1. 3
  2. 2 1 4
  3. 2
  4. 1 1
  5. 2 3

Sample Output 1

  1. 6
  2. 9

If Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.

If Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.

Sample Input 2

  1. 5
  2. 7 2 3 8 5
  3. 3
  4. 4 2
  5. 1 7
  6. 4 13

Sample Output 2

  1. 19
  2. 25
  3. 30
  4.  
  5. */
  6.  
  7. #include <iostream>
  8.  
  9. using namespace std;
    #define h 100100
  10.  
  11. int t[h];
  12.  
  13. int main()
  14. {
        int n;
        cin >> n;
  15. int i = 1;
        while(n --)
        {
            cin >> t[i];
            i ++;
        }
        int m;
        cin >> m;
        while(m --)
        {
            int p, x;
            cin >> p >> x;
            int c;
            c = t[p];
            t[p] = x;
            int sum = 0;
            for(int j = 1; j < i; j ++)
            {
                sum += t[j];
            }
            cout << sum <<endl;
            t[p] = c;
        }
        return 0;
    }

Contest with Drinks Easy的更多相关文章

  1. [arc066f]Contest with Drinks Hard

    题目大意: 有一些物品,每个买了有代价. 如果存在一个极大区间[l,r]内的物品都被买了,这个区间长度为k,可以获得的收益是k*(k+1)/2. 现在若干次询问,每次问假如修改了某个物品的价格,最大收 ...

  2. AtCoder Regular Contest 066 F Contest with Drinks Hard

    题意: 你现在有n个题目可以做,第i个题目需要的时间为t[i],你要选择其中的若干题目去做.不妨令choose[i]表示第i个题目做不做.定义cost=∑(i<=n)∑(i<=j<= ...

  3. 【ARC066】F - Contest with Drinks Hard

    题解 我写的斜率维护,放弃了我最擅长的叉积维护,然后发现叉积维护也不会爆long long哦-- 一写斜率维护我的代码就会莫名变长而且难写--行吧 我们看这题 推了推式子,发现这是个斜率的式子,但是斜 ...

  4. Arc066_F Contest with Drinks Hard

    传送门 题目大意 有一个长为$N$的序列$A$,你要构造一个长为$N$的$01$序列使得$01$序列全部由$1$组成的子串个数$-$两个序列的对应位置两两乘积之和最大,每次独立的询问给定$pos,x$ ...

  5. AtCoder Grand Contest 005F - Many Easy Problems

    $n \leq 200000$的树,从树上选$k$个点的一个方案会对$Ans_k$产生大小为“最小的包括这$k$个点的连通块大小”的贡献.求每个$Ans_k$.膜924844033. 看每个点对$An ...

  6. @atcoder - ARC066F@ Contest with Drinks Hard

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定序列 T1, T2, ... TN,你可以从中选择一些 Ti ...

  7. [atARC066F]Contest with Drinks Hard

    先不考虑修改,那么很明显即对于每一个极长的的区间,若其长度为$l$,有${l+1\choose 2}$的贡献 考虑dp去做,即$f_{i}$表示前$i$个数最大的答案,则$$f_{i}=\max(\m ...

  8. AT2274 [ARC066D] Contest with Drinks Hard

    先考虑不修改怎么做,可以令 \(dp_i\) 表示前 \(i\) 个题能获得的最大得分.那么我们有转移: \[dp_i = \min\{dp_{i - 1}, dp_{j} + \frac{(i - ...

  9. AtCoder Beginner Contest 050 ABC题

    A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...

随机推荐

  1. 吴裕雄 oracle 存储过程

  2. win10自带IE上不了网的解决办法

    1.cmd以管理员身份运行powershell. 2.输入以下三条程序. netsh int tcp set heuristics disabled 回车执行后再输入 netsh int tcp se ...

  3. nltk的使用

    1. 命令行; import nltk nltk.download() #下载相关模型等,...

  4. ssh架构之hibernate(一)简单使用hibernate完成CRUD

    1.Hibernate简介   Hibernate是一个开放源代码的对象关系映射(ORM)框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,h ...

  5. 1.3.5、CDH 搭建Hadoop在安装之前(端口---Cloudera Search使用的端口)

    Cloudera Search使用的端口 在下表中,每个端口的“ 访问要求”列通常是“内部”或“外部”.在此上下文中,“内部”表示端口仅用于组件之间的通信; “外部”表示该端口可用于内部或外部通信. ...

  6. java分解质因数,具体程序分析和代码

    题目:将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. 将一个正整数分解质因数分析:对n进行分解质因数,找到最小的质数k如果这个质数恰好等于n则说明分解质因数过程已经结束,打印输出 ...

  7. 安装FP

    一.安装Oracle 11.2 64-bit数据库 1.安装数据库软件并将SEINESCM数据库还原到服务器上, 2.配置监听和TNS信息 二.安装数据库32位客户端(为SSIS配套使用).安装ORA ...

  8. java 连接sqlserver数据库

    1.ResultSet executeQuery(String sql):执行某条查询语句并返回结果public static void main(String[] args) throws Exce ...

  9. try cache

    try{ $did = DB::insert('vmi_sales_orders',array_keys($value))->values($value)->execute('newerp ...

  10. A class of finite groups with abelian 2-Sylow subgroups By CHIH-HAN SAH

    Remark: 1.An element of a group which conjugate to its inverse is called a real element. If $G$ has ...