Submission #69106432


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ex exit(0)
#define ln cout<<'\n'
#define ll long long
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.12f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll calc(ll a,ll c,ll m) {
  a-=m*2;
  c-=m;
  ll ans=m;
  ans+=min(a,c/2);
  return ans;
}

void Init() {}
void Main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll d=min({a,b,c});
  a-=d;b-=d;c-=d;
  ll l=0,r=min(a/2,c)+1;
  rep(tt,100) {
    ll m1=(l*2+r)/3,m2=(l+r*2)/3;
    ll d1=calc(a,c,m1),d2=calc(a,c,m2);
    if(d1<d2) l=m1;
    else r=m2;
  }
  ll ans=0;
  REP(i,-10,10) {
    ll m=l+i;
    if(m>=0&&m<=min(a/2,c)) ans=max(ans,calc(a,c,m)+d);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Init();ll T=1;if(1)R T;while(T--)Main();return 0;}

Submission Info

Submission Time
Task C - AtCoder AAC Contest
User kzyKT
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1519 Byte
Status AC
Exec Time 160 ms
Memory 3608 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 14
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3388 KiB
01_random_01.txt AC 159 ms 3440 KiB
01_random_02.txt AC 160 ms 3464 KiB
01_random_03.txt AC 160 ms 3416 KiB
01_random_04.txt AC 160 ms 3464 KiB
01_random_05.txt AC 159 ms 3464 KiB
01_random_06.txt AC 159 ms 3468 KiB
01_random_07.txt AC 159 ms 3436 KiB
01_random_08.txt AC 160 ms 3524 KiB
01_random_09.txt AC 159 ms 3464 KiB
01_random_10.txt AC 160 ms 3440 KiB
01_random_11.txt AC 160 ms 3608 KiB
01_random_12.txt AC 160 ms 3396 KiB
01_random_13.txt AC 123 ms 3456 KiB