/*

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:

N
T1 T2 TN
M
P1 X1
P2 X2
:
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

3
2 1 4
2
1 1
2 3

Sample Output 1

6
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

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

Sample Output 2

19
25
30 */ #include <iostream> using namespace std;
#define h 100100 int t[h]; int main()
{
    int n;
    cin >> n;
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. ubuntu16.04获取root权限并用root用户登录

    写在全面:如果根据以下教程涉及到只读文件需要更改文件权限才能需修改文件内容,参考我的另一篇博客:https://www.cnblogs.com/masbay/p/10744900.html中的第2条. ...

  2. putty 链接亚马逊服务器

    使用 PuTTY 从 Windows 连接到亚马逊云的 Linux 实例 转载 2016年07月22日 14:09:47   使用 PuTTY 从 Windows 连接到亚马逊云的 Linux 实例 ...

  3. ubuntu下zaibbix3.2报警搭建

    1.安装sudo apt install sendmail 2.测试发送邮件: echo "正文!" | mail -s 标题 XXX@qq.com 3.成功后继续安装邮件服务器. ...

  4. Error:Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]

    原文博客链接:https://blog.csdn.net/chniccs/article/details/51258972 在创建fragment时,你可能在打包时碰到如下错误 Error:Error ...

  5. Java 动态代理 两种实现方法

    AOP的拦截功能是由java中的动态代理来实现的.说白了,就是在目标类的基础上增加切面逻辑,生成增强的目标类(该切面逻辑或者在目标类函数执行之前,或者目标类函数执行之后,或者在目标类函数抛出异常时候执 ...

  6. 1.3.3、CDH 搭建Hadoop在安装之前(端口---CDH组件使用的端口)

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

  7. sql 求max和min,但是第二大,第二小怎么算?

    利用子查询,但这样速度较慢. SELECT Baoming.id, Baoming.addtime AS '报名时间', CONCAT(Members.realname,Members.usernam ...

  8. android TextView SetText卡顿原因

    [android TextView SetText卡顿原因] 不要用wrap_content即可. 参考:http://blog.csdn.net/self_study/article/details ...

  9. 大数据入门到精通2--spark rdd 获得数据的三种方法

    通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...

  10. SQL Server 2008中SQL增强之一:Values新用途 001

    连接集合 select '1' as id,'wang' as name union select '2' as id,'admin' as name 现在可以这么写了 select id,name ...