Recover the Arrays

  • + 0 comments
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.util.regex.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int[] file = new int[n];
            for(int file_i=0; file_i < n; file_i++){
                file[file_i] = in.nextInt();
            }
            int j=0;
            int count=0;
            while(j<file.length){
                
                for(int i = file[j];i>=0;i--){
                    j++;
                }
                count++;
            }
            System.out.println(count);
        }
    }