結果

問題 No.161 制限ジャンケン
ユーザー かりあげクンかりあげクン
提出日時 2020-08-20 21:14:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,146 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 172,956 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 19:16:41
合計ジャッジ時間 2,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma region template

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using i8  = std::int8_t;using i16 = std::int16_t;using i32 = std::int32_t;using i64 = std::int64_t;using u8  = std::uint8_t;using u16 = std::uint16_t;using u32 = std::uint32_t;using u64 = std::uint64_t;using f32 = float;using f64 = double;using vi32  = std::vector<i32>;using vu32 = std::vector<u32>;using vi64 = std::vector<i64>;using vu64 = std::vector<u64>;using vvi32 = std::vector<vi32>;using vvu32 = std::vector<vu32>;using vvi64 = std::vector<vi64>;using vvu64 = std::vector<vu64>;using pi32 = std::pair<i32,i32>;using pi64 = std::pair<i64,i64>;
#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) for(i64 i=1LL; i<=static_cast<i64>(n); ++i)
#define RFOR(i,a,b) for(i64 i=(a), i##_len=(b); i>i##_len; --i)
#define RFORS(i,n) RFOR(i,n,0)

#define ALL(obj) (obj).begin(),(obj).end()
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define SZ(obj) (static_cast<i32>(obj.size()))
#define cauto const auto&
#define pb push_back
#define mp make_pair

const i32 dx[4]={1,0,-1,0};
const i32 dy[4]={0,1,0,-1};
const i32 INF32 = 0x3F3F3F3F;
const i64 INF64 = 0x3F3F3F3F3F3F3F3F;
const i64 MOD   = 1000000007;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct IoSetup {
    IoSetup() {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(10);
        std::cerr << std::fixed << std::setprecision(10);
    }
}iosetup;

template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first >> p.second;return is; }
template<typename A, typename B> std::ostream &operator<<(std::ostream &os, const std::pair<A, B>& p) { os << p.first << ' ' << p.second;return os; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for(T& in : v) is >> in; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for(i32 i = 0; i < SZ(v); i++) os << v[i] << (i+1 != SZ(v) ? " " : ""); return os; }

// input
u32 G, C, P;
std::string S;

// dp table


void run() {
    using namespace std;
    // your code here
    cin >> G >> C >> P;
    cin >> S;

    i32 ans = 0;
    for (int i = 0; i < static_cast<int>(S.size()); i++) {
        if (S[i] == 'C') {
            if (G > 0) {
                G--;
                ans+=3;
            } else if (C > 0) {
                C--;
                ans++;
            }
        } else if (S[i] == 'P') {
            if (C > 0) {
                C--;
                ans+=3;
            } else if (P > 0) {
                P--;
                ans++;
            }
        } else {
            if (P > 0) {
                P--;
                ans+=3;
            } else if (G > 0) {
                G--;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    run();
}

#pragma endregion template
0