結果

問題 No.3068 Speedrun (Hard)
ユーザー Rac
提出日時 2025-03-22 17:37:35
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,096 bytes
コンパイル時間 4,209 ms
コンパイル使用メモリ 295,680 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-22 17:37:53
合計ジャッジ時間 17,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#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;
  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      long long n = N - i - j, t = T - P * i - Q *  j;
      if (n >= 0 && t >= 0) [[likely]] {
        if (R == S) [[unlikely]] {
          if (t == R * n) {
            if (n <= C){
              cout << i << ' ' << j << ' ' << n << ' ' << 0 << endl;
              return 0;
            } else if (n <= C + D){
              cout << i << ' ' << j << ' ' << C << ' ' << n - C << endl;
              return 0;
            }
          }
        } else {
          if ((n * S - t) % (S - R) == 0 && (t - n * R) % (S - R) == 0) [[likely]] {
            long long x = (n * S - t) / (S - R);
            long long y = (t - n * R) / (S - R);
            if (0 <= x && x <= C && 0 <= y && y <= D){
              cout << i << ' ' << j << ' ' << x << ' ' << y << endl;
              return 0;
            }
          }
        }
      }
    }
  }
}
0