結果
問題 |
No.3068 Speedrun (Hard)
|
ユーザー |
|
提出日時 | 2025-03-21 22:11:58 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,823 bytes |
コンパイル時間 | 5,785 ms |
コンパイル使用メモリ | 173,400 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-21 22:12:09 |
合計ジャッジ時間 | 7,358 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 TLE * 1 |
other | -- * 32 |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; int A[4]; int B[4]; int N,T; unordered_map <string,int> memo; string func(int X,int Y) { string a = ""; string b = ""; while(a.length() < 9) { a = (char)(X%10 + '0') + a; X/=10; } while(b.length() < 5) { b = (char)(Y%10 + '0') + b; Y/=10; } return a + b; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> A[0] >> A[1] >> A[2] >> A[3] >> N; cin >> B[0] >> B[1] >> B[2] >> B[3] >> T; for(int x=0;x<=A[0];x++){ if(x > N) break; if(x*B[0] > T) break; for(int y=0;y<=A[1];y++) { if(y > N) break; if(x+y > N) break; int X = x + y; int Y = B[0]*x + B[1]*y; if(Y > T) break; string s = func(X,Y); //cout << X << ' ' << Y << ' ' << s << '\n'; if(memo.find(s)==memo.end()) memo[s] = x; } } for(int x=0;x<=A[2];x++){ if(x > N) break; if(x*B[2] > T) break; for(int y=0;y<=A[3];y++) { if(y > N) break; if(x+y > N) break; int X = x + y; int Y = B[2]*x + B[3]*y; if(Y > T) break; string s = func(N-X,T-Y); // cout << N - X << ' ' << T - Y << ' ' << s << '\n'; if(memo.find(s)!=memo.end()) { int a1 = memo[s]; int a2 = N - a1 - x - y; int a3 = x; int a4 = y; cout << a1 << ' ' << a2 << ' ' << a3 << ' ' << a4 << '\n'; return 0; } } } return 0; }