結果

問題 No.3557 KCPC or KUPC 2
コンテスト
ユーザー ha_chan
提出日時 2026-05-29 19:21:51
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,269 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,693 ms
コンパイル使用メモリ 331,200 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-29 19:22:02
合計ジャッジ時間 3,962 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点1 10 % AC * 15 WA * 15
部分点2 40 % AC * 25 WA * 5
部分点3 50 % AC * 30
合計 50 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back

LL maxx=LL(1000000000)*1000000000;

LL wa(LL a,LL b){
  if(a>=maxx-b){return maxx;}
  return a+b;
}

LL seki(LL a,LL b){
  if(b==0){return 0;}
  if(a>=maxx/b){return maxx;}
  return a*b;
}

LL g(LL a,LL b,LL c,LL t){
  LL k=t/b;
  LL p=wa(a,seki(k,c));
  LL ans=seki(p,t-k*b);
  ans=wa(ans,seki(a,seki(k,b)));
  p=seki(k,k-1)/2;
  p=seki(p,b);
  p=seki(p,c);
  ans=wa(ans,p);
  return ans;
}

LL f(LL n,LL a,LL b,LL c){
  LL l=0,r=n,t;
  while(r-l>1){
    //cout<<l<<' '<<r<<endl;
    t=(r+l)/2;
    //cout<<g(a,b,c,t)<<endl;
    if(g(a,b,c,t)<n){l=t;}
    else{r=t;}
  }
  return r;
}

int main() {std::ios_base::sync_with_stdio(false);   std::cin.tie(NULL);
  LL n,a,b,c,d,e,ff;
  cin>>n>>a>>b>>c>>d>>e>>ff;
  LL p=f(n,a,b,c),q=f(n,d,e,ff);
  if(p==q){cout<<"Same"<<endl;}
  else if(p<q){cout<<"KCPC"<<endl;}
  else{cout<<"KUPC"<<endl;}
}
0