結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++){
    cin >> X[i];
  }
  vector<vector<int>> C(N, vector<int>(M));
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cin >> C[i][j];
    }
    cin >> T[i];
  }
  vector<pair<vector<int>, int>> P(N);
  for (int i = 0; i < N; i++){
    P[i].first.resize(M);
    for (int j = 0; j < M; j++){
      P[i].first[j] = T[i] * C[i][j];
    }
    P[i].second = i;
  }
  sort(P.begin(), P.end());
  bool ok = false;
  for (int i = 0; i < N; i++){
    if (T[i] == 100){
      if (X == C[i]){
        ok = true;
      }
    } else {
      vector<int> R(M);
      bool ok2 = true;
      for (int j = 0; j < M; j++){
        R[j] = 10000 * X[j] - 100 * T[i] * C[i][j];
        if (R[j] % (100 - T[i]) != 0){
          ok2 = false;
        }
        R[j] /= 100 - T[i];
      }
      if (ok2){
        int p = lower_bound(P.begin(), P.end(), make_pair(R, -1)) - P.begin();
        if (p < N){
          if (P[p].first == R){
            if (P[p].second != i){
              ok = true;
            } else if (p < N - 1){
              if (P[p + 1].first == R){
                ok = true;
              }
            }
          }
        }
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0