結果

問題 No.2684 折々の色
ユーザー GOTKAKO
提出日時 2024-03-20 23:02:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 863 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 207,648 KB
最終ジャッジ日時 2025-02-20 09:59:19
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M; cin >> N >> M;
    vector<int> X(M),T(N);
    vector<vector<int>> C(N);
    for(auto &x : X) cin >> x,x *= 10000;


    multiset<vector<int>> S;
    for(int i=0; i<N; i++){
        vector<int> now(M);
        for(auto &n : now) cin >> n;
        int t; cin >> t;
        for(auto &n : now) n *= t;
        S.insert(now);
        C.at(i) = now; T.at(i) = t;
    }

    bool yes = false;
    for(int i=0; i<N; i++){
        vector<int> goal = X;
        bool ok = true;
        int t = T.at(i);
        if(t == 100){
            for(int k=0; k<M; k++) goal.at(k) /= 100;
            if(goal == C.at(i)){yes = true; break;}
            continue;
        }
        t = 100-t;
        for(int k=0; k<M; k++){
            goal.at(k) -= 100*C.at(i).at(k);
            if(goal.at(k) >= 0){
                if(goal.at(k)%(t)){ok = false; break;}
                goal.at(k) /= t;
            }
            else{ok = false; break;}
        }
        S.erase(S.find(C.at(i)));
        if(S.count(goal) && ok){yes = true; break;}
        S.insert(C.at(i));
    }
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0