-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeforces1.cpp
More file actions
50 lines (50 loc) · 978 Bytes
/
codeforces1.cpp
File metadata and controls
50 lines (50 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
int p,f,cnts,cntw,s,w;
cin>>p>>f>>cnts>>cntw>>s>>w;
int tp,tf,one=1,two=1;
while(tp<=p)
{
tp=one*s+two*w;
one++;
two++;
if(one>p)
{
one=cnts;
}
if(two>w)
{
two=cntw;
}
}
one--;
two--;
int sum=one+two;
int none=cnts-one;
int ntwo=cntw-two;
one=0;
two=0;
while(tf<=f)
{
tf=one*s+two*w;
one++;
two++;
if(one>none)
{
one=none;
}
if(two>ntwo)
{
two=ntwo;
}
}
sum+=one+two;
cout<<sum<<endl;
}
}