Language: C++


            left = middle;  
        }  
    }  
    int pos = left;  
    if(t[right]<=x){  
        pos = right;  
    }  
    return pos;  
}  
bool vis[maxn];  
int main(){  
    int i,j;  
    scanf("%d%d%d",&n,&c,&k);  
    for(i=1;i<=n;i++){  
        scanf("%lld",t+i);  
    }  
    sort(t+1, t+1+n);  
    memset(vis, true, sizeof(vis));  
    int p = 1;  
    int kpos;  
    long long res = 0;  
    int last = -1;  
    while(vis[n]){  
        kpos = findpos(p, t[p]+k);  
        int another = (kpos-p+1)%c;  
        res += (kpos-p+1)/c;  
        for(i=p;i<=kpos-another;i++){  
            vis[i] = false;  
        }  
        p = kpos - another+1;  
        if(p == last){  
            res++;  
            for(i=p;i<=kpos;i++){  
                vis[i] =false;  
            }  
            p = kpos + 1;  
            continue;  
        }  
        last = p;  
    }  
    printf("%lld\n",res);  
    return 0;  
}  


Compiler output:
a.cc:2:13: error: 'left' does not name a type
    2 |             left = middle;
      |             ^~~~
a.cc:3:9: error: expected declaration before '}' token
    3 |         }
      |         ^
a.cc:4:5: error: expected declaration before '}' token
    4 |     }
      |     ^
a.cc:5:15: error: 'left' was not declared in this scope
    5 |     int pos = left;
      |               ^~~~
a.cc:6:5: error: expected unqualified-id before 'if'
    6 |     if(t[right]<=x){
      |     ^~
a.cc:9:5: error: expected unqualified-id before 'return'
    9 |     return pos;
      |     ^~~~~~
a.cc:10:1: error: expected declaration before '}' token
   10 | }
      | ^
a.cc:11:10: error: 'maxn' was not declared in this scope
   11 | bool vis[maxn];
      |          ^~~~
a.cc: In function 'int main()':
a.cc:14:21: error: 'n' was not declared in this scope
   14 |     scanf("%d%d%d",&n,&c,&k);
      |                     ^
a.cc:14:24: error: 'c' was not declared in this scope
   14 |     scanf("%d%d%d",&n,&c,&k);
      |                        ^
a.cc:14:27: error: 'k' was not declared in this scope
   14 |     scanf("%d%d%d",&n,&c,&k);
      |                           ^
a.cc:14:5: error: 'scanf' was not declared in this scope
   14 |     scanf("%d%d%d",&n,&c,&k);
      |     ^~~~~
a.cc:16:22: error: 't' was not declared in this scope
   16 |         scanf("%lld",t+i);
      |                      ^
a.cc:18:10: error: 't' was not declared in this scope
   18 |     sort(t+1, t+1+n);
      |          ^
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(t+1, t+1+n);
      |     ^~~~
      |     short
a.cc:19:12: error: 'vis' was not declared in this scope
   19 |     memset(vis, true, sizeof(vis));
      |            ^~~
a.cc:19:5: error: 'memset' was not declared in this scope
   19 |     memset(vis, true, sizeof(vis));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | 
a.cc:25:16: error: 'findpos' was not declared in this scope
   25 |         kpos = findpos(p, t[p]+k);
      |                ^~~~~~~
a.cc:42:5: error: 'printf' was not declared in this scope
   42 |     printf("%lld\n",res);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 |