Language: Java

#include <stdio.h>
#define MAX 100000
long long T[MAX];
int n,k;
 
int load(long long P) {
    int i=0,j=0;
    long long t;
    for(i = 0; i < k; i++) {
        t = 0;
        while( t+T[j] <=P) {
            t +=T[j];
            j++;
            if(j==n) return n;  
        }
    }
    return j;   
     
}
 
int solve() {
    long long right = MAX*10000,left=0,mid,s;
     
    while(right>left+1) {
        mid = (right + left)/2;
         s=load(mid);
         if(s>=n) right=mid;
         else left = mid;
    }
        return right;           
}
 
int main(void)
 
{
    int i;
    scanf("%d %d%",&n,&k);
     
    for(i=0; i < n; i++) {
        scanf("%d",&T[i]);
    }
        printf("%llu\n",solve());
   return 0;       
     
     
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
         ^
Main.java:2: error: illegal character: '#'
#define MAX 100000
^
Main.java:4: error: class, interface, enum, or record expected
int n,k;
^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
int load(long long P) {
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: <identifier> expected
int load(long long P) {
             ^
Main.java:8: error: class, interface, enum, or record expected
    long long t;
    ^
Main.java:9: error: class, interface, enum, or record expected
    for(i = 0; i < k; i++) {
    ^
Main.java:9: error: class, interface, enum, or record expected
    for(i = 0; i < k; i++) {
               ^
Main.java:9: error: class, interface, enum, or record expected
    for(i = 0; i < k; i++) {
                      ^
Main.java:11: error: class, interface, enum, or record expected
        while( t+T[j] <=P) {
        ^
Main.java:13: error: class, interface, enum, or record expected
            j++;
            ^
Main.java:14: error: class, interface, enum, or record expected
            if(j==n) return n;  
            ^
Main.java:15: error: class, interface, enum, or record expected
        }
        ^
Main.java:19: error: class, interface, enum, or record expected
}
^
Main.java:24: error: class, interface, enum, or record expected
    while(right>left+1) {
    ^
Main.java:26: error: class, interface, enum, or record expected
         s=load(mid);
         ^
Main.java:27: error: class, interface, enum, or record expected
         if(s>=n) right=mid;
         ^
Main.java:28: error: class, interface, enum, or record expected
         else left = mid;
         ^
Main.java:29: error: class, interface, enum, or record expected
    }
    ^
Main.java:31: error: class, interface, enum, or record expected
}
^
Main.java:37: error: class, interface, enum, or record expected
    scanf("%d %d%",&n,&k);
    ^
Main.java:39: error: class, interface, enum, or record expected
    for(i=0; i < n; i++) {
    ^
Main.java:39: error: class, interface, enum, or record expected
    for(i=0; i < n; i++) {
             ^
Main.java:39: error: class, interface, enum, or record expected
    for(i=0; i < n; i++) {
                    ^
Main.java:41: error: class, interface, enum, or record expected
    }
    ^
Main.java:43: error: class, interface, enum, or record expected
   return 0;       
   ^
Main.java:46: error: class, interface, enum, or record expected
}
^
28 errors