Result: Accepted
Time: 3ms
Memory: 2540kB
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<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = 100010;
const int inf = 0x3f3f3f3f;
const int modu = 1e9+7;
int n,m,k,t,sum,sum1,ans,cnt;
int x,y,z,w;
int a[maxn],b[maxn];
string s;
int main(){
cin>>t;
while(t--){
sum=0;
ans=0;
cin>>x>>y;
cin>>z>>w;
cin>>s;
sum+=(s[0]-'0')*600+(s[1]-'0')*60+(s[3]-'0')*10+s[4]-'0';
sum-=300;
sum1=sum+y;
if(sum1>1139) sum1=1139;
if(sum<w) ans=(sum+y)/z;
else{
if((sum1)%z==0) ans=(sum1)/z;
else ans=(sum1)/z+1;
if(w<z){
if(sum%z>=w) {
cnt=sum/z+1;
}
else {
cnt=sum/z;
}
}
else {
cnt=(sum-(w-z))/z;
}
ans-=cnt;
}
cout<<ans<<endl;
}
}