結果

問題 No.3068 Speedrun (Hard)
ユーザー keisuke6
提出日時 2025-03-21 22:31:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,096 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 194,124 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-21 22:31:46
合計ジャッジ時間 8,865 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int a,b,c,d,n,p,q,r,s,t;
    cin>>a>>b>>c>>d>>n>>p>>q>>r>>s>>t;
    for(int i=0;i<=a;i++)for(int j=0;j<=b;j++){
    	int lt = t-i*p-j*q;
    	int ln = n-i-j;
    	// x+y = ln;
    	// rx+sy = lt;
    	// sx+sy = s*ln;
    	// y = (lt-s*ln)/(t-s)
    	// x = ln-y
    	int x,y;
    	if(s == r){
    		x = min(c,ln);
    		y = ln-x;
    	}
    	else{
    		y = (lt-r*ln)/(s-r);
    		x = ln-y;
    	}
    	if(i*p+j*q+x*r+y*s != t || y < 0 || x < 0 || y > d || x > c){
    		continue;
    	}
    	cout<<i<<' '<<j<<' '<<x<<' '<<y<<endl;
    	return 0;
    }
}
0