fork download
  1. #include <bits/stdc++.h>
  2. #define MAX 1000005
  3. #define ll long long
  4. #define upperlimit 1000100
  5. #define INF 1e18
  6. #define eps 1e-12
  7. #define endl '\n'
  8. #define pcc pair<char,char>
  9. #define pii pair<int,int>
  10. #define pll pair<ll,ll>
  11. #define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
  12. #define MOD 1000000007LL
  13. #define slld(t) scanf("%lld",&t)
  14. #define sd(t) scanf("%d",&t)
  15. #define pd(t) printf("%d\n",t)
  16. #define plld(t) printf("%lld\n",t)
  17. #define mp(a,b) make_pair(a,b)
  18. #define FF first
  19. #define SS second
  20. #define pb(x) push_back(x)
  21. #define vi vector<int>
  22. #define vll vector<ll>
  23. #define clr(a) memset(a,0,sizeof(a))
  24. #define debug(a) printf("check%d\n",a)
  25. #define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  26. using namespace std;
  27.  
  28. ll gcd(ll n1,ll n2){
  29. if(n2==0)
  30. return n1;
  31. if(n1%n2==0)return n2;
  32. return gcd(n2,n1%n2);
  33. }
  34. ll powmod(ll base,ll exponent)
  35. {
  36. if(exponent<0) exponent+=MOD-1;
  37. ll ans=1;
  38. while(exponent){
  39. if(exponent&1)ans=(ans*base)%MOD;
  40. base=(base*base)%MOD;
  41. exponent/=2;
  42. }
  43. return ans;
  44. }
  45. int n;
  46. double w,v;
  47. vector<double> x;
  48. double check(double mkc,double t)
  49. {
  50. double ww=mkc/v;
  51. double bc=(t-ww)/w;
  52. bc=ceil(bc);
  53. return bc*w+(x[n-1]-x[0])/v;
  54. }
  55. int main()
  56. {
  57. csl;
  58. cin>>n;
  59. for(int i=1;i<=n;i++)
  60. {
  61. int bb;
  62. cin>>bb;
  63. x.pb(bb);
  64. }
  65. cin>>w>>v;
  66. int q;
  67. cin>>q;
  68. while(q--)
  69. {
  70. double p,t,u;
  71. cin>>p>>t>>u;
  72. int i=lower_bound(x.begin(), x.end(),p)-x.begin();
  73. double ans=min(check(x[i],t+fabs(p-x[i])/u),check(x[i-1],t+fabs(p-x[i-1])/u));
  74. ans=min(ans,t+fabs(x[n-1]-p)/u);
  75. printf("%0.9lf\n", ans);
  76. }
  77. }
Success #stdin #stdout 0s 4228KB
stdin
Standard input is empty
stdout
Standard output is empty