Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
#include <vector>
int main(){
const long S = 2001;
long cur(1); std::vector<long> v;
long n; scanf("%ld", &n);
for(long p = 0; p < n; p++){
long x; scanf("%ld", &x);
if(x == cur){v.push_back(p); ++cur;}
}
printf("%ld\n", v.size());
for(long p = 0; p < v.size(); p++){printf("%ld ", S + v[p]);}
puts("");
return 0;
}
Copy The Code &
Try With Live Editor
Input
10
-2 1 1 3 2 3 4 -10 -2 5
-2 1 1 3 2 3 4 -10 -2 5
Output
5
2002 2005 2006 2007 2010
2002 2005 2006 2007 2010
Demonstration
Codeforces Solution-B. Company Income Growth-Solution in C, C++, Java, Python