結果

問題 No.1292 パタパタ三角形
ユーザー kaede2020kaede2020
提出日時 2020-11-20 22:06:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,066 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 177,272 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 19:19:01
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//#define endl "\n"
typedef pair<ll, ll> P;
const ll INF = 1e18;
//using mint = modint1000000007;
//using mint = modint998244353;
//const int INF=INT_MAX;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}

int main(){
  string s,t;
  cin>>s;
  rep(i,s.size()){
    if(s[i]!=s[i+1]){
      t.push_back(s[i]);
    }
  }
  map<char,int>mp;
  rep(i,t.size()){
    mp[t[i]]++;
  }
  vector<int>a(3);
  a[0]=mp['a'];
  a[1]=mp['b'];
  a[2]=mp['c'];
  sort(a.begin(),a.end());
  int sa1=a[1]-a[0];
  int sa2=a[2]-a[1];
  int ans=a[0]*3+1;
  if(sa1*2>=6)ans+=5;
  else if(sa2>0)ans+=sa1*2+1;
  else ans+=sa1*2;
  cout<<ans<<endl;
  return 0;
}
0