結果

問題 No.3068 Speedrun (Hard)
ユーザー SSRS
提出日時 2025-03-21 22:00:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 569 ms / 2,000 ms
コード長 1,139 bytes
コンパイル時間 3,168 ms
コンパイル使用メモリ 217,004 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-21 22:00:21
合計ジャッジ時間 7,389 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D, N;
  cin >> A >> B >> C >> D >> N;
  int P, Q, R, S, T;
  cin >> P >> Q >> R >> S >> T;
  if (R == S){
    for (int i = 0; i <= A; i++){
      for (int j = 0; j <= B; j++){
        int n = N - i - j, t = T - P * i - Q * j;
        if (t == R * n && n >= 0 && n <= C + D){
          if (n <= C){
            cout << i << ' ' << j << ' ' << n << ' ' << 0 << endl;
            return 0;
          } else {
            cout << i << ' ' << j << ' ' << C << ' ' << n - C << endl;
            return 0;
          }
        }
      }
    }
  } else {
    for (int i = 0; i <= A; i++){
      for (int j = 0; j <= B; j++){
        int n = N - i - j, t = T - P * i - Q * j;
        if ((n * S - t) % (S - R) == 0){
          int x = (n * S - t) / (S - R);
          int y = (t - n * R) / (S - R);
          if (0 <= x && x <= C && 0 <= y && y <= D){
            cout << i << ' ' << j << ' ' << x << ' ' << y << endl;
            return 0;
          }
        }
      }
    }   
  }
}
0