Codeforces 534c-polycarpus ' Dice (IDEA)

Source: Internet
Author: User

Test instructions: given n (1 <= n <= 2*10^5) dice, given the maximum number of times each dice can be thrown (the minimum number is always 1), given the number of points thrown by all the dice and a, it is not possible to throw a few points per dice.

Consider the maximum and minimum conditions and make the difference (see the code comment for details)

#include <cstdio>#include<cstring>#include<cctype>#include<cstdlib>#include<cmath>#include<iostream>#include<sstream>#include<iterator>#include<algorithm>#include<string>#include<vector>#include<Set>#include<map>#include<deque>#include<queue>#include<stack>#include<list>typedefLong Longll; typedef unsignedLong LongLlu; Const intMAXN = -+Ten; Const intMaxt =200000+Ten; Const intINF =0x7f7f7f7f; Const DoublePI = ACOs (-1.0); Const DoubleEPS = 1e-6; using namespacestd; intN;        ll A[maxt], A; intMain () {scanf ("%d%i64d", &n, &A); ll Allsum=0;//the total maximum value of all dice Max added up     for(inti =0; I < n; ++i) {scanf ("%i64d", A +i); Allsum+=A[i]; }       for(inti =0; I < n; ++i) {ll down= Max (1ll, A-(allsum-a[i]));//Dice minimum = required and-Other dice have all the maximum valuesll up = min (A[i], A-(N-1));//Dice max = required and-all other dice minimum value        if(i) printf (" "); printf ("%i64d", A[i]-(Up-down +1));//The number that cannot occur = The number that can be represented in total-the number that is already able to represent    }      return 0; }  

Codeforces 534c-polycarpus ' Dice (IDEA)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.