提出 #64359927


ソースコード 拡げる

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int64_t N, std::string S) {
    const string s = "PAKENCAMP";
    vector<int> cnt(26), cntS(26);
    for (char i : s) cnt[i - 'A']++;
    int ans = 0;
    for (char i : S) cntS[i - 'A']++;
    rep(i, 26) {
        if (!cnt[i] && cntS[i]) return -1;
        if (cnt[i]) ans = max(ans, (cntS[i] + cnt[i] - 1) / cnt[i]);
    }
    return ans;
}

// generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int64_t N;
    std::string S;
    std::cin >> N >> S;
    auto ans = solve(N, S);
    std::cout << ans << '\n';
    return 0;
}

提出情報

提出日時
問題 B - Pakencamp
ユーザ delta71
言語 C++ 20 (gcc 12.2)
得点 100
コード長 1038 Byte
結果 AC
実行時間 1 ms
メモリ 3684 KiB

コンパイルエラー

Main.cpp: In function ‘int64_t solve(int64_t, std::string)’:
Main.cpp:10:23: warning: unused parameter ‘N’ [-Wunused-parameter]
   10 | int64_t solve(int64_t N, std::string S) {
      |               ~~~~~~~~^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 3
AC × 18
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_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, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3336 KiB
00_sample_01.txt AC 1 ms 3460 KiB
00_sample_02.txt AC 1 ms 3464 KiB
01_random_00.txt AC 1 ms 3336 KiB
01_random_01.txt AC 1 ms 3560 KiB
01_random_02.txt AC 1 ms 3520 KiB
01_random_03.txt AC 1 ms 3576 KiB
01_random_04.txt AC 1 ms 3468 KiB
01_random_05.txt AC 1 ms 3684 KiB
01_random_06.txt AC 1 ms 3584 KiB
01_random_07.txt AC 1 ms 3520 KiB
01_random_08.txt AC 1 ms 3472 KiB
01_random_09.txt AC 1 ms 3440 KiB
02_handmade_00.txt AC 1 ms 3616 KiB
02_handmade_01.txt AC 1 ms 3620 KiB
02_handmade_02.txt AC 1 ms 3624 KiB
02_handmade_03.txt AC 1 ms 3464 KiB
02_handmade_04.txt AC 1 ms 3468 KiB