結果

問題 No.2372 既視感
ユーザー momoyuu
提出日時 2023-07-08 00:14:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,173 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 114,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-21 20:37:55
合計ジャッジ時間 2,639 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
using ll = long long;


int main(){
    int n,k,q;
    cin>>n>>k>>q;
    deque<string> que;
    while(q--){
        int op;
        cin>>op;
        if(op==1){
            string a;
            cin>>a;
            que.push_back(a);
            while(que.size()>n) que.pop_front();
        }else{
            vector<string> a(6);
            vector<int> t(6);
            for(int i = 0;i<6;i++) cin>>a[i]>>t[i];
            int now = 0;
            int ni = 0;
            deque<string> use;
            for(int i = 0;i<6;i++){
                int need = t[i];
                bool ok = false;
                for(int j = 0;j<que.size();j++) ok |= (que[j] == a[i]);
                if(ok) need = min(need,k);
                if(now+need<=60){
                    now += need;
                    ni++;
                    use.push_back(a[i]);
                }else break;
            }
            cout<<ni<<endl;
            for(int i = 0;i<use.size();i++) que.push_back(use[i]);
            while(que.size()>n) que.pop_front();
        }
    }

}

0