Submission #343890

# Submission time Handle Problem Language Result Execution time Memory
343890 2021-01-04T17:16:49 Z KWang31 Money (IZhO17_money) Java 11
Compilation error
0 ms 0 KB
import java.io.*; import java.util.*;
public class A{
  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        
    } 
    public static class Pair implements Comparable<Pair>{
        int vtx; int val;
        public Pair(int a, int b){
            this.vtx=a; this.val=b;
        }
        public int compareTo(Pair other){
            if(this.val<other.val)return -1;
            if(this.val>other.val)return 1;
            if(this.vtx<other.vtx)return -1;
            return 1;
        }
    }
    static int MOD=998244353;
    static int[] tree; static int MAXN=1000001;
    public static void main(String[] args){
        FastReader br=new FastReader();
        int N=br.nextInt(); int[] a=new int[N];
        for(int i=0;i<N;i++){
          a[i]=br.nextInt();
        }
        tree=new int[MAXN];
        int ans=0; int ii;
        for(int i=0; i<N; i++){
           ii=i+1; ans++;
           while(ii<N && a[ii]>=a[ii-1] && sum(a[ii])==sum(a[ii-1])){
              ii++;
           }
           for(int j=i;j<ii; j++){
             upd(a[j]);
           }
          //The segment [i,ii-1] can be used
          i=ii-1;
        }
      System.out.println(ans);
    }
     //tree[i]=sum(i-2^{\nu_2(i)}+1,i)
    public static int sum(int i){//This is a consequence of unique expression in base 2
        int ans=0;
        while(i>0){
            ans+=tree[i];
            i-=(i&-i);
        }
        return ans;
    }
    public static void update(int i){//Increment arr[i] by k
        while(i<=N){
            tree[i]++;
            i+=(i&-i);// Note (k&-k) is the largest power of 2 dividing k
            //These intervals all contain i
        }
    }
    
  
}
//Debugging:
//Are you sure your algorithm is correct?
//Bounds: long
//Special cases: n=0,1?
//Make sure you remove your debugging code before you submit!

Compilation message

money.java:2: error: class A is public, should be declared in a file named A.java
public class A{
       ^
money.java:65: error: cannot find symbol
             upd(a[j]);
             ^
  symbol:   method upd(int)
  location: class A
money.java:82: error: cannot find symbol
        while(i<=N){
                 ^
  symbol:   variable N
  location: class A
3 errors