fork download
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cmath>
  4. #include <iostream>
  5. #include <iomanip>
  6. #include <sstream>
  7. #include <string>
  8. #include <vector>
  9. #include <algorithm>
  10. #include <queue>
  11. #include <stack>
  12. #include <set>
  13.  
  14. using namespace std;
  15.  
  16. double F[150000],P[150000];
  17. int p[150000];
  18.  
  19. int main(){
  20. int n,m,C;
  21.  
  22. scanf("%d %d %d",&n,&m,&C);
  23.  
  24. int x[n];
  25.  
  26. for(int i = 0;i < n;++i) scanf("%d",&x[i]);
  27. for(int i = 1;i < n;++i) scanf("%d",&p[i]);
  28.  
  29. P[0] = 0;
  30. for(int i = 1;i < n;++i)
  31. P[i] = P[i - 1] + p[i] / 100.0;
  32.  
  33. for(int i = 0;i < n;++i)
  34. F[i] = x[i] / 2.0 - C * P[i];
  35.  
  36. double ans = 0;
  37.  
  38. for(int i = 0,xa,xb;i < m;++i){
  39. scanf("%d %d",&xa,&xb);
  40. --xa; --xb;
  41.  
  42. double aux = 0,mn = F[xa];
  43.  
  44. for(int j = xa;j <= xb;++j){
  45. mn = min(mn,F[j]);
  46. aux = max(aux,F[j] - mn);
  47. }
  48.  
  49. ans += aux;
  50. }
  51.  
  52. printf("%.8f\n",ans);
  53.  
  54. return 0;
  55. }
  56.  
Runtime error #stdin #stdout 0.01s 5652KB
stdin
Standard input is empty
stdout
Standard output is empty