結果

問題 No.2372 既視感
ユーザー hiro71687khiro71687k
提出日時 2023-07-12 17:18:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 2,006 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 218,052 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 07:38:24
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,352 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 3 ms
4,352 KB
testcase_27 AC 3 ms
4,352 KB
testcase_28 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ld inf=10000999999999900;
int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    map<string,ll>memo;
    queue<string>que;
    vector<ll>ans;
    for (ll i = 0; i < q; i++)
    {
        ll t;
        cin >> t;
        if (t==1)
        {
            string s;
            cin >> s;
            memo[s]++;
            que.push(s);
            while (que.size()>n)
            {
                string t=que.front();
                que.pop();
                memo[t]--;
            }
        }else{
            vector<string>t(6);
            vector<ll>d(6);
            for (ll j = 0; j < 6; j++)
            {
                cin >> t[j] >> d[j];
            }
            ll a=0,x=0;
            bool ok=true;
            for (ll j = 0; j < 6; j++)
            {
                x++;
                if (memo[t[j]]>=1)
                {
                    a+=min(k,d[j]);
                    if (a>60)
                    {
                        a-=min(k,d[j]);
                        x--;
                        ok=false;
                        break;
                    }
                }else{
                    a+=d[j];
                    if (a>60)
                    {
                        a-=d[j];
                        x--;
                        ok=false;
                        break;
                    }
                }
                if (!ok)
                {
                    break;
                }
            }
            for (ll j = 0; j < x; j++)
            {
                memo[t[j]]++;
                que.push(t[j]);
            }
            while (que.size()>n)
            {
                string s=que.front();
                que.pop();
                memo[s]--;
            }
            ans.push_back(x);
        }
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    
}
0