fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. return 0;#include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10. void FAST_IO() {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(0);
  13. cout.tie(0);
  14. }
  15.  
  16. #define REP(_i, _a) for(int _i = 0; _i < _a; ++_i)
  17. #define FOR(_i, _a, _b) for(int _i = _a; _i <= _b; ++_i)
  18. #define FORD(_i, _a, _b) for(int _i = _a; _i >= _b; --_i)
  19. #define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
  20. #define ALL(_a) _a.begin(), _a.end()
  21. #define SIZE(_a) _a.size()
  22. #define pb push_back
  23. #define eb emplace_back
  24. #define mp make_pair
  25. #define fi first
  26. #define se second
  27. #define newline '\n';
  28.  
  29. // DEBUG UTIL
  30. #define DEBUG(args...) { cerr << "> "; \
  31. string _s = #args; \
  32. replace(_s.begin(), _s.end(), ',', ' '); \
  33. stringstream _ss(_s); istream_iterator<string> _it(_ss); \
  34. err(_it, args); }
  35.  
  36. void err(istream_iterator<string> it) { cerr << endl; }
  37. template<typename T, typename... Args>
  38. void err(istream_iterator<string> it, T a, Args... args) {
  39. cerr << *it << ": " << a << " ";
  40. err(++it, args...);
  41. }
  42.  
  43. typedef long long ll;
  44. typedef pair<int, int> ii;
  45. typedef pair<int, int> pii;
  46. typedef pair<ll, ll> pll;
  47. typedef pair<double, double> pdd;
  48. typedef vector<int> vi;
  49. typedef vector<vi> vvi;
  50. typedef vector<ii> vii;
  51.  
  52. const double PI = acos(-1.0);
  53. const int MOD = 1e9 + 7;
  54. const int INF = 2e9;
  55.  
  56. const int MAX_N = 1e3 + 5;
  57.  
  58. int N, U;
  59. vi arr;
  60.  
  61. int main() {
  62. FAST_IO();
  63.  
  64. cin >> N >> U;
  65. REP(i, N) {
  66. int a;
  67. cin >> a;
  68. arr.pb(a);
  69. }
  70.  
  71. auto it_k = arr.begin();
  72.  
  73. double ans = -1.0;
  74.  
  75. while (it_k != arr.end()) {
  76.  
  77. auto it_i = lower_bound(arr.begin(), it_k, *it_k - U);
  78.  
  79. if (it_i != it_k && *it_i >= *it_k - U) {
  80. int i = *it_i;
  81. ++it_i;
  82. if (it_i != it_k) {
  83. int j = *it_i;
  84. int k = *it_k;
  85.  
  86. ans = max(ans, ((double)(k-j))/(double)(k-i));
  87. }
  88. }
  89. ++it_k;
  90. }
  91.  
  92. cout << fixed << setprecision(10) << ans << endl;
  93.  
  94. return 0;
  95. }
  96. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:11: error: stray ‘#’ in program
  return 0;#include <bits/stdc++.h>
           ^
prog.cpp: In function ‘int main()’:
prog.cpp:6:12: error: ‘include’ was not declared in this scope
  return 0;#include <bits/stdc++.h>
            ^~~~~~~
prog.cpp:6:21: error: ‘bits’ was not declared in this scope
  return 0;#include <bits/stdc++.h>
                     ^~~~
prog.cpp:6:26: error: ‘stdc’ was not declared in this scope
  return 0;#include <bits/stdc++.h>
                          ^~~~
prog.cpp:8:1: error: expected primary-expression before ‘using’
 using namespace std;
 ^~~~~
prog.cpp:10:16: error: a function-definition is not allowed here before ‘{’ token
 void FAST_IO() {
                ^
prog.cpp:36:10: error: variable or field ‘err’ declared void
 void err(istream_iterator<string> it) { cerr << endl; }
          ^~~~~~~~~~~~~~~~
prog.cpp:36:10: error: ‘istream_iterator’ was not declared in this scope
prog.cpp:36:33: error: expected primary-expression before ‘>’ token
 void err(istream_iterator<string> it) { cerr << endl; }
                                 ^
prog.cpp:36:35: error: ‘it’ was not declared in this scope
 void err(istream_iterator<string> it) { cerr << endl; }
                                   ^~
prog.cpp:37:1: error: a template declaration cannot appear at block scope
 template<typename T, typename... Args>
 ^~~~~~~~
prog.cpp:46:14: error: ‘ll’ was not declared in this scope
 typedef pair<ll, ll> pll;
              ^~
prog.cpp:46:18: error: the value of ‘ll’ is not usable in a constant expression
 typedef pair<ll, ll> pll;
                  ^~
prog.cpp:46:14: note: ‘ll’ was not declared ‘constexpr’
 typedef pair<ll, ll> pll;
              ^~
prog.cpp:46:20: error: template argument 1 is invalid
 typedef pair<ll, ll> pll;
                    ^
prog.cpp:46:20: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _T1, class _T2> struct std::pair’
prog.cpp:46:20: note:   expected a type, got ‘ll’
prog.cpp:48:9: error: ‘vector’ does not name a type
 typedef vector<int> vi;
         ^~~~~~
prog.cpp:49:9: error: ‘vector’ does not name a type
 typedef vector<vi> vvi;
         ^~~~~~
prog.cpp:50:9: error: ‘vector’ does not name a type
 typedef vector<ii> vii;
         ^~~~~~
prog.cpp:52:28: error: ‘acos’ was not declared in this scope
 const double PI = acos(-1.0);
                            ^
prog.cpp:59:1: error: ‘vi’ was not declared in this scope
 vi arr;
 ^~
prog.cpp:61:12: error: a function-definition is not allowed here before ‘{’ token
 int main() {
            ^
prog.cpp:96:1: error: expected ‘}’ at end of input
 }
 ^
stdout
Standard output is empty