Submission #1083908

# Submission time Handle Problem Language Result Execution time Memory
1083908 2024-09-04T13:56:14 Z duytuandao21 Sjeckanje (COCI21_sjeckanje) Java 11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 2e6 + 7;
const int inf = 1e9 + 7;
const long long infll = 1e18 + 7;
typedef pair< float, int > ii;

int n, q;
int a[N];

long long GetResult() {
    vector<long long> dp(n + 1, 0);
    long long res = -infll;
    for (int i = 1; i <= n; i++) {
        int maxValue = -inf;
        int minValue = inf;
        for (int j = i; j > 0; j--) {
            maxValue = max(maxValue, a[j]);
            minValue = min(minValue, a[j]);
            dp[i] = max(dp[i], dp[j - 1] + maxValue - minValue);
            res = max(res, dp[i]);
        }
        // cout << dp[i] << ' ';
    }   
    return res;
} 
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    while (q--) {
        int l, r, v; cin >> l >> r >> v;
        for (int i = l; i <= r; i++) a[i] += v;
        cout << GetResult();
        if (q > 0) cout << '\n';
    }
    return 0;
}

Compilation message

Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
Main.java:4: error: class, interface, or enum expected
const int N = 2e6 + 7;
^
Main.java:5: error: class, interface, or enum expected
const int inf = 1e9 + 7;
^
Main.java:6: error: class, interface, or enum expected
const long long infll = 1e18 + 7;
^
Main.java:7: error: class, interface, or enum expected
typedef pair< float, int > ii;
^
Main.java:9: error: class, interface, or enum expected
int n, q;
^
Main.java:10: error: class, interface, or enum expected
int a[N];
^
Main.java:12: error: class, interface, or enum expected
long long GetResult() {
^
Main.java:14: error: class, interface, or enum expected
    long long res = -infll;
    ^
Main.java:15: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) {
    ^
Main.java:15: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) {
                    ^
Main.java:15: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) {
                            ^
Main.java:17: error: class, interface, or enum expected
        int minValue = inf;
        ^
Main.java:18: error: class, interface, or enum expected
        for (int j = i; j > 0; j--) {
        ^
Main.java:18: error: class, interface, or enum expected
        for (int j = i; j > 0; j--) {
                        ^
Main.java:18: error: class, interface, or enum expected
        for (int j = i; j > 0; j--) {
                               ^
Main.java:20: error: class, interface, or enum expected
            minValue = min(minValue, a[j]);
            ^
Main.java:21: error: class, interface, or enum expected
            dp[i] = max(dp[i], dp[j - 1] + maxValue - minValue);
            ^
Main.java:22: error: class, interface, or enum expected
            res = max(res, dp[i]);
            ^
Main.java:23: error: class, interface, or enum expected
        }
        ^
Main.java:27: error: class, interface, or enum expected
} 
^
Main.java:30: error: class, interface, or enum expected
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                                  ^
Main.java:30: error: class, interface, or enum expected
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                                              ^
Main.java:31: error: class, interface, or enum expected
    cin >> n >> q;
    ^
Main.java:32: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) cin >> a[i];
    ^
Main.java:32: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) cin >> a[i];
                    ^
Main.java:32: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++) cin >> a[i];
                            ^
Main.java:33: error: class, interface, or enum expected
    while (q--) {
    ^
Main.java:34: error: class, interface, or enum expected
        int l, r, v; cin >> l >> r >> v;
                     ^
Main.java:35: error: class, interface, or enum expected
        for (int i = l; i <= r; i++) a[i] += v;
        ^
Main.java:35: error: class, interface, or enum expected
        for (int i = l; i <= r; i++) a[i] += v;
                        ^
Main.java:35: error: class, interface, or enum expected
        for (int i = l; i <= r; i++) a[i] += v;
                                ^
Main.java:36: error: class, interface, or enum expected
        cout << GetResult();
        ^
Main.java:37: error: class, interface, or enum expected
        if (q > 0) cout << '\n';
        ^
Main.java:38: error: class, interface, or enum expected
    }
    ^
Main.java:40: error: class, interface, or enum expected
}
^
37 errors