Advertisement
leminhkt

noname36 (DDUONG02)

Apr 4th, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define f first
  5. #define s second
  6. #define lFOR(i, a, b) for(ll i=(a); i<=(b); i++)
  7. #define lFORn(i, n) for(ll i=1; i<=(n); i++)
  8. #define lFORx(i, a, b, n) for(ll i=(a); i<=(b); i+=(x))
  9. #define FORa(i, b) for(i; i<=(b); i++)
  10. #define FORax(i, b, x) for(i; i<=(b); i+=(x))
  11. #define lFORR(i, a, b) for(ll i=(a); i>=(b); i--)
  12. #define lFORRn(i, n) for(ll i=(n); i>=1; i--)
  13. #define lFORRx(i, a, b, n) for(ll i=(a); i>=(b); i-=(x))
  14. #define FORRa(i, b) for(i; i>=(b); i--)
  15. #define FORRax(i, b, x) for(i; i>=(b); i-=(x))
  16. #define iFOR(i, a, b) for(int i=(a); i<=(b); i++)
  17. #define iFORn(i, n) for(int i=1; i<=(n); i++)
  18. #define iFORx(i, a, b, n) for(int i=(a); i<=(b); i+=(x))
  19. #define iFORR(i, a, b) for(int i=(a); i>=(b); i--)
  20. #define iFORRn(i, n) for(int i=(n); i>=1; i--)
  21. #define iFORRx(i, a, b, n) for(int i=(a); i>=(b); i-=(x))
  22. #define pb(x) push_back(x)
  23. #define all(x) (x).begin(), (x).end()
  24. #define sz(x) (x).size()
  25. #define sqr(x) (ll)(x)*(x)
  26. #define PI (2*acos(0))
  27. using namespace std;
  28.  
  29. template <typename T>
  30. inline void Read(T& x)
  31. {
  32.     bool Neg = false;
  33.     char c;
  34.     for (c = getchar(); c < '0' || c > '9'; c = getchar())
  35.         if (c == '-') Neg = !Neg;
  36.     x = c - '0';
  37.     for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
  38.         x = x * 10 + c - '0';
  39.     if (Neg) x = -x;
  40. }
  41. template <typename T>
  42. inline void Write(T x)
  43. {
  44.     if (x < 0)
  45.     {
  46.         putchar('-'); x = -x;
  47.     }
  48.     T p = 1;
  49.     for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
  50.     for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
  51. }
  52.  
  53. void update(int* n){
  54.     *n=(*n<4)?((*n==2)?3:5):((*n-1)%6)?(*n+2):(*n+4);
  55. }
  56. bool cprm(int n){
  57.     if(n==2||n==3) return 1;
  58.     if(n<2||n%2==0||n%3==0) return 0;
  59.     for(int i=5; i<=sqrt(n); update(&i)) if(n%i==0) return 0;
  60.     return 1;
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.         //=================declare=================
  69.     int n, k, u, v;
  70.     pair<int, int> s[100005];
  71.  
  72.  
  73.  
  74.  
  75.  
  76. //=================..end..=================
  77.         //=================function=================
  78.    
  79.  
  80.  
  81.  
  82.  
  83. //=================..end...=================
  84. int main(){
  85.     //freopen("DDUONG.inp", "r", stdin);
  86.     //freopen("DDUONG.out", "w", stdout);
  87.     //ios_base::sync_with_stdio(0); cin.tie(0);
  88.         //=================code=================
  89.     Read(n); Read(k);
  90.     iFORn(i, n){
  91.         Read(s[i].f);
  92.         s[i].f+=s[i-1].f-k,
  93.         s[i].s=i;
  94.     }
  95.     sort(s+1, s+1+n);
  96.     iFOR(i, 2, n)
  97.         if(s[i].f==s[i-1].f){
  98.             if(s[i].s-s[i-1].s+1>v)
  99.                 u=s[i-1].s+1,
  100.                 v=s[i].s-s[i-1].s;
  101.             s[i].s=s[i-1].s;
  102.         }
  103.     if(v){
  104.         Write(u);
  105.         cout<<'\n';
  106.     }
  107.     Write(v);
  108.  
  109.  
  110.  
  111.  
  112. //=================end.=================
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement