标签:ural
input | output |
---|---|
1000000000 2 800000000 800000000 |
600000000 |
1000000000 2 500000000 500000000 |
0 |
题意:有n个人,有m种语言,然后m个输入代表每种语言有几个人会讲,要求会讲所有语言的人有几个
思路:对于两种语言的话,我们不难发现必然是a1+a2-n,那么我们以此类推,先求出会讲两种语言的人数,在把会讲两种语言的人看做一种,循环计算下去求得会讲所有语言的人有几个
#include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <algorithm> using namespace std; #define ls 2*i #define rs 2*i+1 #define up(i,x,y) for(i=x;i<=y;i++) #define down(i,x,y) for(i=x;i>=y;i--) #define mem(a,x) memset(a,x,sizeof(a)) #define w(a) while(a) #define LL long long const double pi = acos(-1.0); #define Len 200005 #define mod 19999997 const int INF = 0x3f3f3f3f; LL n,m,N,M; int main() { w(~scanf("%I64d%I64d",&n,&m)) { LL t = n,x; w(m--) { scanf("%I64d",&x); t = max(0LL,t+x-n); } printf("%I64d\n",t); } return 0; }
标签:ural
原文地址:http://blog.csdn.net/libin56842/article/details/45133693