結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー ytqm3ytqm3
提出日時 2021-11-12 22:50:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,124 bytes
コンパイル時間 2,189 ms
コンパイル使用メモリ 205,560 KB
実行使用メモリ 9,644 KB
最終ジャッジ日時 2023-08-17 03:11:32
合計ジャッジ時間 34,939 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1,487 ms
9,448 KB
testcase_05 AC 1,590 ms
9,392 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 501 ms
6,632 KB
testcase_09 AC 863 ms
8,420 KB
testcase_10 AC 629 ms
5,476 KB
testcase_11 WA -
testcase_12 AC 46 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 1,006 ms
7,676 KB
testcase_15 AC 1,301 ms
9,264 KB
testcase_16 AC 598 ms
4,988 KB
testcase_17 AC 551 ms
6,224 KB
testcase_18 AC 769 ms
6,124 KB
testcase_19 AC 454 ms
6,212 KB
testcase_20 WA -
testcase_21 AC 888 ms
8,252 KB
testcase_22 AC 1,142 ms
8,568 KB
testcase_23 AC 1,573 ms
9,384 KB
testcase_24 AC 1,584 ms
9,484 KB
testcase_25 AC 1,562 ms
9,644 KB
testcase_26 WA -
testcase_27 AC 1,567 ms
9,108 KB
testcase_28 WA -
testcase_29 AC 1,602 ms
9,060 KB
testcase_30 AC 1,571 ms
9,436 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 4 ms
4,380 KB
testcase_39 AC 6 ms
4,376 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 AC 3 ms
4,376 KB
testcase_42 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
using namespace std;

void solve();

int main(){
  cout<<fixed<<setprecision(0);
  bool is_multicase=false;
  int T=1;
  if(is_multicase){
    cin>>T;
  }
  for(int i=0;i<T;++i){
    solve();
  }
  return 0;
}

template<typename T> void turtle_in(T& n){
  cin>>n;
}

template<typename T,typename U> void turtle_in(pair<T,U>& p){
  turtle_in(p.first);
  turtle_in(p.second);
}

template<typename T> void turtle_in(vector<T>& v){
  for(auto& u:v){
    turtle_in(u);
  }
}

template<typename T> void turtle_out(T& n){
  cout<<n;
}

template<typename T,typename U> void turtle_out(pair<T,U>& p){
  cout<<"{";
  turtle_out(p.first);
  cout<<", ";
  turtle_out(p.second);
  cout<<"}";
}

template<typename T> void turtle_out(vector<T>& v){
  for(int i=0;i<int(v.size());++i){
    turtle_out(v[i]);
    if(i!=v.size()-1){
      cout<<" ";
    }
  }
  cout<<endl;
}

template<typename T> void turtle_out(vector<vector<T>>& v){
  for(int i=0;i<int(v.size());++i){
    turtle_out(v[i]);
  }
}

void scan(){}

template<typename T,class... Args> void scan(T& n,Args&... args){
  turtle_in(n);
  scan(args...);
}

void print(){}

template<typename T,class... Args> void print(T n,Args... args){
  turtle_out(n);
  print(args...);
}

template<typename T> void println(T n){
  turtle_out(n);
  cout<<endl;
}

template<typename T,class... Args> void println(T n,Args... args){
  turtle_out(n);
  cout<<" ";
  println(args...);
}

template<u64 mod> struct modint{
  u64 val;
  modint(i64 val_=0):val((val_%i64(mod)+i64(mod))%i64(mod)){}
  modint operator-(){
    return modint(mod-val);
  }
  modint operator+(modint rhs){
    return modint(*this)+=rhs;
  }
  modint operator-(modint rhs){
    return modint(*this)-=rhs;
  }
  modint operator*(modint rhs){
    return modint(*this)*=rhs;
  }
  modint operator/(modint rhs){
    return modint(*this)/=rhs;
  }
  modint &operator+=(modint rhs){
    val+=rhs.val;
    val-=((val>=mod)?mod:0);
    return (*this);
  }
  modint &operator-=(modint rhs){
    val+=((val<rhs.val)?mod:0);
    val-=rhs.val;
    return (*this);
  }
  modint &operator*=(modint rhs){
    val=val*rhs.val%mod;
    return (*this);
  }
  modint &operator/=(modint rhs){
    u64 ex=mod-2;
    modint now=1;
    while(ex){
      now*=((ex&1)?rhs:1);
      rhs*=rhs,ex>>=1;
    }
    return (*this)*=now;
  }
  bool operator==(modint rhs){
    return val==rhs.val;
  }
  bool operator!=(modint rhs){
    return val!=rhs.val;
  }
  friend std::ostream &operator<<(std::ostream& os,modint x){
    return os<<(x.val);
  }
  friend std::istream &operator>>(std::istream& is,modint& x){
    u64 t;
    is>>t,x=t;
    return is;
  }
};

template<typename T,typename U> T power(T a,U n){
  T res=1;
  while(n>0){
    if(n%2==1){
      res*=a;
    }
    a*=a;
    n/=2;
  }
  return res;
}

template<typename T> struct genrand{
  uniform_int_distribution<T> gen;
  mt19937 engine;
  genrand(T a,T b):gen(a,b){
    random_device seed_gen;
    engine.seed(seed_gen());
  }
  T operator()(){
    return gen(engine);
  }
};

template<typename T> struct comb{
  vector<T> dat,idat;
  comb(int mx=3000000):dat(mx+1,1),idat(mx+1,1){
    for(int i=1;i<=mx;++i){
      dat[i]=dat[i-1]*i;
    }
    idat[mx]/=dat[mx];
    for(int i=mx;i>0;--i){
      idat[i-1]=idat[i]*i;
    }
  }
  T operator()(int n,int k){
    if(n<0||k<0||n<k){
      return 0;
    }
    return dat[n]*idat[k]*idat[n-k];
  }
};

bool sub(i64 N,i64 A,i64 B,i64 X,i64 Y,vector<i64> H,i64 x){
    for(int i=0;i<N;++i){
        H[i]-=x;
    }
    multiset<i64> T;
    for(int i=0;i<N;++i){
        T.insert(H[i]);
    }
    while(A--){
        i64 v=(*prev(T.end()));
        T.erase(prev(T.end()));
        T.insert(v-X);
    }
    i64 sum=0;
    for(auto v:T){
        sum+=max(i64(0),v);
    }
    return sum<=B*Y;
}

void solve(){
  i64 N,A,B,X,Y;
  scan(N,A,B,X,Y);
  vector<i64> H(N);
  scan(H);
  i64 ok=1e9+5,ng=0;
  while(1<std::abs(ok-ng)){
      i64 mid=(ok+ng)/2;
      bool f=sub(N,A,B,X,Y,H,mid);
      if(f){
          ok=mid;
      }
      else{
          ng=mid;
      }
  }
  println(ok);
}
0