fork download
  1. #include <cmath>
  2. #include <map>
  3. #include<fstream>
  4. #include<algorithm>
  5. #include <iostream>
  6. #include<numeric>
  7. #include<utility>
  8. #include<functional>
  9. #include<stdio.h>
  10. #include <iomanip>
  11. #include<assert.h>
  12. #include<memory.h>
  13. #include<bitset>
  14. #include<algorithm>
  15. #include <cassert>
  16. #include <stack>
  17. #include<cstring>
  18. #include <cmath>
  19. #include <complex>
  20. #include <sstream>
  21. #include<cstring>
  22. #include <complex>
  23. #include<cstdlib>
  24. #include <set>
  25. #include <ctime>
  26. #include <queue>
  27. #include <vector>
  28. #include <iterator>
  29. #include <math.h>
  30. #include <cstdio>
  31. #include<map>
  32. using namespace std;
  33. #define ll long long
  34. #define MAXN 110005
  35. #define fast std::ios_base::sync_with_stdio(false);
  36. #define sz(x) ((int)(x.size()))
  37. #define REP(i,v) for(int i = 0 ; i < sz(v) ; ++i)
  38. vector<int> v;
  39. int DP[100001];
  40. int main()
  41. {
  42.  
  43. int n;
  44. scanf("%d",&n);
  45. v.resize(n);
  46. for(int i = 0; i < n ; ++i)
  47. {
  48. scanf("%d",&v[i]); --v[i];
  49. DP[v[i]] = i;
  50. }
  51. for(int i = n - 2 ; i >= 0 ; --i)
  52. {
  53. DP[i] = max(DP[i],DP[i + 1]);
  54. }
  55. int ans = -1;
  56. for(int i = 0 ; i < n ; ++i)
  57. {
  58. if(v[i] != n - 1 && DP[v[i]] - i > 0)
  59. ans = max(ans,DP[v[i]] - i);
  60.  
  61. }
  62. cout << ans;
  63.  
  64. }
  65.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <cmath>
^
Main.java:1: error: class, interface, or enum expected
#include <cmath>
         ^
Main.java:2: error: illegal character: '#'
#include <map>
^
Main.java:3: error: illegal character: '#'
#include<fstream>
^
Main.java:4: error: illegal character: '#'
#include<algorithm>
^
Main.java:5: error: illegal character: '#'
#include <iostream>
^
Main.java:6: error: illegal character: '#'
#include<numeric>
^
Main.java:7: error: illegal character: '#'
#include<utility>
^
Main.java:8: error: illegal character: '#'
#include<functional>
^
Main.java:9: error: illegal character: '#'
#include<stdio.h>
^
Main.java:10: error: illegal character: '#'
#include <iomanip>
^
Main.java:11: error: illegal character: '#'
#include<assert.h>
^
Main.java:12: error: illegal character: '#'
#include<memory.h>
^
Main.java:13: error: illegal character: '#'
#include<bitset>
^
Main.java:14: error: illegal character: '#'
#include<algorithm>
^
Main.java:15: error: illegal character: '#'
#include <cassert>
^
Main.java:16: error: illegal character: '#'
#include <stack>
^
Main.java:17: error: illegal character: '#'
#include<cstring>
^
Main.java:18: error: illegal character: '#'
#include <cmath>
^
Main.java:19: error: illegal character: '#'
#include <complex>
^
Main.java:20: error: illegal character: '#'
#include <sstream>
^
Main.java:21: error: illegal character: '#'
#include<cstring>
^
Main.java:22: error: illegal character: '#'
#include <complex>
^
Main.java:23: error: illegal character: '#'
#include<cstdlib>
^
Main.java:24: error: illegal character: '#'
#include <set>
^
Main.java:25: error: illegal character: '#'
#include <ctime>
^
Main.java:26: error: illegal character: '#'
#include <queue>
^
Main.java:27: error: illegal character: '#'
#include <vector>
^
Main.java:28: error: illegal character: '#'
#include <iterator>
^
Main.java:29: error: illegal character: '#'
#include <math.h>
^
Main.java:30: error: illegal character: '#'
#include <cstdio>
^
Main.java:31: error: illegal character: '#'
#include<map>
^
Main.java:33: error: illegal character: '#'
#define ll long long
^
Main.java:33: error: class, interface, or enum expected
#define ll long long
        ^
Main.java:34: error: illegal character: '#'
#define MAXN 110005
^
Main.java:35: error: illegal character: '#'
#define fast std::ios_base::sync_with_stdio(false);
^
Main.java:36: error: illegal character: '#'
#define sz(x) ((int)(x.size()))
^
Main.java:36: error: class, interface, or enum expected
#define sz(x) ((int)(x.size()))
        ^
Main.java:37: error: illegal character: '#'
#define REP(i,v) for(int i = 0 ; i < sz(v) ; ++i)
^
Main.java:37: error: class, interface, or enum expected
#define REP(i,v) for(int i = 0 ; i < sz(v) ; ++i)
                                 ^
Main.java:37: error: class, interface, or enum expected
#define REP(i,v) for(int i = 0 ; i < sz(v) ; ++i)
                                             ^
Main.java:39: error: class, interface, or enum expected
int DP[100001];
^
Main.java:40: error: class, interface, or enum expected
int main()
^
Main.java:44: error: class, interface, or enum expected
	scanf("%d",&n);
	^
Main.java:45: error: class, interface, or enum expected
	v.resize(n);
	^
Main.java:46: error: class, interface, or enum expected
	for(int i = 0; i < n ; ++i)
	^
Main.java:46: error: class, interface, or enum expected
	for(int i = 0; i < n ; ++i)
	               ^
Main.java:46: error: class, interface, or enum expected
	for(int i = 0; i < n ; ++i)
	                       ^
Main.java:48: error: class, interface, or enum expected
		scanf("%d",&v[i]); --v[i];
		                   ^
Main.java:49: error: class, interface, or enum expected
		DP[v[i]] = i;
		^
Main.java:50: error: class, interface, or enum expected
	}
	^
Main.java:51: error: class, interface, or enum expected
	for(int i = n - 2 ; i >= 0 ; --i)
	                    ^
Main.java:51: error: class, interface, or enum expected
	for(int i = n - 2 ; i >= 0 ; --i)
	                             ^
Main.java:54: error: class, interface, or enum expected
	}
	^
Main.java:56: error: class, interface, or enum expected
	for(int i = 0 ; i < n ; ++i)
	^
Main.java:56: error: class, interface, or enum expected
	for(int i = 0 ; i < n ; ++i)
	                ^
Main.java:56: error: class, interface, or enum expected
	for(int i = 0 ; i < n ; ++i)
	                        ^
Main.java:61: error: class, interface, or enum expected
	}
	^
Main.java:64: error: class, interface, or enum expected
}
^
59 errors
stdout
Standard output is empty