Submission #270674

# Submission time Handle Problem Language Result Execution time Memory
270674 2020-08-17T22:11:41 Z Gilgamesh Just Long Neckties (JOI20_ho_t1) Java 11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line
 
int main(){
    setIO();
    int N; cin >> N;
    pii A[N + 1];
    int B[N];
    for(int i = 0; i <= N; ++i){
        cin >> A[i].x;
        A[i].y = i;
    }
    for(int i = 0; i < N; ++i){
        cin >> B[i];
    }
    sort(A, A + N + 1);
    sort(B, B + N);
    int ans[N + 1], dif1[N], dif2[N], suffmx[N], prefmx[N];
    fill(ans, ans + N + 1, 0);
    for(int i = 0; i < N; ++i) {
        dif1[i] = max(A[i].x - B[i], 0);
        dif2[i] = max(A[i + 1].x - B[i], 0);
    }
    for(int i = 0; i < N; ++i) {
        prefmx[i] = dif1[i];
        if(i > 0) prefmx[i] = max(prefmx[i - 1], prefmx[i]);
    }
    for(int i = N - 1; i >= 0; --i) {
        suffmx[i] = dif2[i];
        if(i < N - 1) suffmx[i] = max(suffmx[i], suffmx[i + 1]);
    }
    for(int i = 0; i <= N; ++i) {
        if(i > 0) ans[A[i].y] = prefmx[i - 1];
        if(i < N) ans[A[i].y] = max(ans[A[i].y], suffmx[i]);
    }
    for(int i = 0; i <= N; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

Compilation message

ho_t1.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
ho_t1.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
ho_t1.java:4: error: class, interface, or enum expected
using ll = long long;
^
ho_t1.java:5: error: class, interface, or enum expected
using pii = pair<int, int>;
^
ho_t1.java:7: error: illegal character: '#'
#define pb push_back
^
ho_t1.java:7: error: class, interface, or enum expected
#define pb push_back
        ^
ho_t1.java:8: error: illegal character: '#'
#define mp make_pair
^
ho_t1.java:9: error: illegal character: '#'
#define eb emplace_back
^
ho_t1.java:10: error: illegal character: '#'
#define all(x) (x).begin(),(x).end()
^
ho_t1.java:11: error: illegal character: '#'
#define x first
^
ho_t1.java:12: error: illegal character: '#'
#define y second
^
ho_t1.java:15: error: class, interface, or enum expected
const int dx[] = {0, 0, 1, -1};
^
ho_t1.java:16: error: class, interface, or enum expected
const int dy[] = {1, -1, 0, 0}; 
^
ho_t1.java:17: error: class, interface, or enum expected
const char dir[] = {'R', 'L', 'D', 'U'};
^
ho_t1.java:19: error: class, interface, or enum expected
int add(int a, int b){
^
ho_t1.java:21: error: class, interface, or enum expected
    if(a >= MOD){
    ^
ho_t1.java:23: error: class, interface, or enum expected
    }
    ^
ho_t1.java:25: error: class, interface, or enum expected
}
^
ho_t1.java:29: error: class, interface, or enum expected
    if(a < 0) a += MOD;
    ^
ho_t1.java:30: error: class, interface, or enum expected
    return a;
    ^
ho_t1.java:31: error: class, interface, or enum expected
}
^
ho_t1.java:35: error: class, interface, or enum expected
}
^
ho_t1.java:39: error: class, interface, or enum expected
    cin.tie(0);
    ^
ho_t1.java:42: error: class, interface, or enum expected
}
^
ho_t1.java:52: error: class, interface, or enum expected
    int N; cin >> N;
    ^
ho_t1.java:52: error: class, interface, or enum expected
    int N; cin >> N;
           ^
ho_t1.java:53: error: class, interface, or enum expected
    pii A[N + 1];
    ^
ho_t1.java:54: error: class, interface, or enum expected
    int B[N];
    ^
ho_t1.java:55: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i){
    ^
ho_t1.java:55: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i){
                   ^
ho_t1.java:55: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i){
                           ^
ho_t1.java:57: error: class, interface, or enum expected
        A[i].y = i;
        ^
ho_t1.java:58: error: class, interface, or enum expected
    }
    ^
ho_t1.java:59: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i){
                   ^
ho_t1.java:59: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i){
                          ^
ho_t1.java:61: error: class, interface, or enum expected
    }
    ^
ho_t1.java:63: error: class, interface, or enum expected
    sort(B, B + N);
    ^
ho_t1.java:64: error: class, interface, or enum expected
    int ans[N + 1], dif1[N], dif2[N], suffmx[N], prefmx[N];
    ^
ho_t1.java:65: error: class, interface, or enum expected
    fill(ans, ans + N + 1, 0);
    ^
ho_t1.java:66: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i) {
    ^
ho_t1.java:66: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i) {
                   ^
ho_t1.java:66: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i) {
                          ^
ho_t1.java:68: error: class, interface, or enum expected
        dif2[i] = max(A[i + 1].x - B[i], 0);
        ^
ho_t1.java:69: error: class, interface, or enum expected
    }
    ^
ho_t1.java:70: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i) {
                   ^
ho_t1.java:70: error: class, interface, or enum expected
    for(int i = 0; i < N; ++i) {
                          ^
ho_t1.java:72: error: class, interface, or enum expected
        if(i > 0) prefmx[i] = max(prefmx[i - 1], prefmx[i]);
        ^
ho_t1.java:73: error: class, interface, or enum expected
    }
    ^
ho_t1.java:74: error: class, interface, or enum expected
    for(int i = N - 1; i >= 0; --i) {
                       ^
ho_t1.java:74: error: class, interface, or enum expected
    for(int i = N - 1; i >= 0; --i) {
                               ^
ho_t1.java:76: error: class, interface, or enum expected
        if(i < N - 1) suffmx[i] = max(suffmx[i], suffmx[i + 1]);
        ^
ho_t1.java:77: error: class, interface, or enum expected
    }
    ^
ho_t1.java:78: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i) {
                   ^
ho_t1.java:78: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i) {
                           ^
ho_t1.java:80: error: class, interface, or enum expected
        if(i < N) ans[A[i].y] = max(ans[A[i].y], suffmx[i]);
        ^
ho_t1.java:81: error: class, interface, or enum expected
    }
    ^
ho_t1.java:82: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i) {
                   ^
ho_t1.java:82: error: class, interface, or enum expected
    for(int i = 0; i <= N; ++i) {
                           ^
ho_t1.java:84: error: class, interface, or enum expected
    }
    ^
ho_t1.java:86: error: class, interface, or enum expected
}
^
60 errors