Calabash and Landlord
Quailty and CCPC
#include <bits/stdc++.h> using namespace std; const double eps=1e-6; int n,d; struct node { char name[15]; int x,y; bool operator<(const node &b)const { if (x==b.x) { return y<b.y; } else { return x>b.x; } } }a[101000]; int main() { int _; scanf("%d",&_); while(_--) { scanf("%d%d",&n,&d); for (int i=1; i<=n; i++) { scanf("%s %d %d",a[i].name,&a[i].x,&a[i].y); } sort(a+1,a+n+1); double kk=n*d*0.1; int k=kk; if (fabs(fabs(k-kk)-0.5)<eps) { k++; printf("%s\n",a[k].name); } else { printf("Quailty is very great\n"); } } }
Roundgod and Milk Tea
#include <bits/stdc++.h> using namespace std; const int maxn=1000100; typedef long long ll; ll ans1,ans2,suma,sumb; int a[maxn],b[maxn],n,tmp; int main() { int _; scanf("%d",&_); while (_--) { suma=sumb=0; ans2=0; scanf("%d",&n); for (int i=1; i<=n; i++) { scanf("%d%d",&a[i],&b[i]); suma+=a[i]; sumb+=b[i]; } ans1=min(suma,sumb); for (int i=1; i<=n; i++) { tmp=min(a[i]*1ll,sumb-b[i]); ans2+=tmp; } printf("%lld\n",min(ans1,ans2)); } }