Codeforces|Codeforces Round #608 (Div. 2)

A

#include using namespace std; typedef long long ll; typedef pair pll; templateinline void rd(T &x){x=0; char o,f=1; while(o=getchar(),o<48)if(o==45)f=-f; do x=(x<<3)+(x<<1)+(o^48); while(o=getchar(),o>47); x*=f; } const int inf=~0u>>2; //1073741823 const ll INF=~0ull>>2; //4611686018427387903 const int maxn=1e3+10; ll judge(ll a,ll b,ll c,ll d,ll e,ll f) { ll sum=0; ll num=min(a,d); sum+=e*num; num=min(min(b,c),min(c,d-num)); sum+=f*num; return sum; } ll judge2(ll a,ll b,ll c,ll d,ll e,ll f) { ll sum=0; ll num=min(min(b,c),min(c,d-num)); sum+=f*num; num=min(a,d-num); sum+=e*num; return sum; } void solve() { ll a,b,c,d,e,f; rd(a),rd(b),rd(c),rd(d),rd(e),rd(f); printf("%lld\n",max(judge(a,b,c,d,e,f),judge2(a,b,c,d,e,f))); } int main() { #ifndef ONLINE_JUDGE freopen("hzh.in","r",stdin); //freopen("hzh.out","w",stdout); #endif /* ll T; rd(T); while(T--) */ solve(); return 0; }

B
#include using namespace std; typedef long long ll; typedef pair pll; templateinline void rd(T &x){x=0; char o,f=1; while(o=getchar(),o<48)if(o==45)f=-f; do x=(x<<3)+(x<<1)+(o^48); while(o=getchar(),o>47); x*=f; } const int inf=~0u>>2; //1073741823 const ll INF=~0ull>>2; //4611686018427387903 const int maxn=1e3+10; string s; int n,b=0,w=0,num=0; vectorans; void solve() { rd(n); for(int i=0; i

【Codeforces|Codeforces Round #608 (Div. 2)】C
#include using namespace std; typedef long long ll; typedef pair pll; templateinline void rd(T &x){x=0; char o,f=1; while(o=getchar(),o<48)if(o==45)f=-f; do x=(x<<3)+(x<<1)+(o^48); while(o=getchar(),o>47); x*=f; } const int inf=~0u>>2; //1073741823 const ll INF=~0ull>>2; //4611686018427387903 const int maxn=1e3+10; int n,sx,sy,x,y,ansx,ansy,maxx,u,d,l,r; void solve() { rd(n),rd(sx),rd(sy); while(n--) { rd(x),rd(y); if(x>sx) r++; if(x) l++; if(y>sy) u++; if(y) d++; } if(l>=r&&l>=u&&l>=d) { maxx=l; ansx=sx-1; ansy=sy; } else if(r>=l&&r>=u&&r>=d) { maxx=r; ansx=sx+1; ansy=sy; } else if(u>=l&&u>=r&&u>=d) { maxx=u; ansx=sx; ansy=sy+1; } else if(d>=l&&d>=r&&d>=u) { maxx=d; ansx=sx; ansy=sy-1; } printf("%d\n%d %d\n",maxx,ansx,ansy); } int main() { #ifndef ONLINE_JUDGE freopen("stdin.in","r",stdin); //freopen("stdout.out","w",stdout); #endif /* ll T; rd(T); while(T--) */ solve(); return 0; }

    推荐阅读