【瞎搞】 ZJU 3219 Average Score
小学数学题
#include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cctype> #include <cmath> #include <string> #include <sstream> #include <iostream> #include <algorithm> #include <iomanip> using namespace std; #include <queue> #include <stack> #include <vector> #include <deque> #include <set> #include <map> typedef long long LL; typedef long double LD; #define pi acos(-1.0) #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 typedef pair<int, int> PI; typedef pair<int, PI> PP; #ifdef _WIN32 #define LLD "%I64d" #else #define LLD "%lld" #endif const int MAXN = 200100; const int INF = 999999; //LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;} //inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;} //inline void print(LL x){printf(LLD, x);puts("");} //inline void read(int &x){char c = getchar();while(c < '0') c = getchar();x = c - '0'; c = getchar();while(c >= '0'){x = x * 10 + (c - '0'); c = getchar();}} int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); #endif int t,a,b,n; scanf("%d", &t); while(t--) { int n,m; scanf("%d%d",&n,&m); int a,sum2=0,sum1=0; for(int i=0;i<n-1;i++) { scanf("%d",&a); sum1+=a; } for(int i=0;i<m;i++) { scanf("%d",&a); sum2+=a; } int minn=9999,maxx=0; for(int i=0;i<=100;i++) { if(sum1*1.0/(n-1)>(sum1+i)*1.0/n&&sum2*1.0/m<(sum2+i)*1.0/(m+1)) { minn=min(minn,i); maxx=max(maxx,i); } } printf("%d %d\n",minn,maxx); } return 0; }