Submission #537483

# Submission time Handle Problem Language Result Execution time Memory
537483 2022-03-15T07:08:58 Z andrei_boaca Stove (JOI18_stove) Java 11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll n,v[100005],k;
vector<int> vals;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(int i=1;i<n;i++)
        vals.push_back(v[i]-v[i+1]);
    sort(vals.begin(),vals.end());
    ll suma=0;
    for(int j=0;j+1<k;j++)
        suma+=vals[j];
    suma+=k;
    suma-=v[1];
    suma+=v[n];
    cout<<suma;
    return 0;
}

Compilation message

stove.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
stove.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
stove.java:4: error: class, interface, or enum expected
typedef long long ll;
^
stove.java:5: error: class, interface, or enum expected
ll n,v[100005],k;
^
stove.java:6: error: class, interface, or enum expected
vector<int> vals;
^
stove.java:7: error: class, interface, or enum expected
int main()
^
stove.java:10: error: class, interface, or enum expected
    for(int i=1;i<=n;i++)
    ^
stove.java:10: error: class, interface, or enum expected
    for(int i=1;i<=n;i++)
                ^
stove.java:10: error: class, interface, or enum expected
    for(int i=1;i<=n;i++)
                     ^
stove.java:12: error: class, interface, or enum expected
    sort(v+1,v+n+1);
    ^
stove.java:13: error: class, interface, or enum expected
    for(int i=1;i<n;i++)
    ^
stove.java:13: error: class, interface, or enum expected
    for(int i=1;i<n;i++)
                ^
stove.java:13: error: class, interface, or enum expected
    for(int i=1;i<n;i++)
                    ^
stove.java:15: error: class, interface, or enum expected
    sort(vals.begin(),vals.end());
    ^
stove.java:16: error: class, interface, or enum expected
    ll suma=0;
    ^
stove.java:17: error: class, interface, or enum expected
    for(int j=0;j+1<k;j++)
    ^
stove.java:17: error: class, interface, or enum expected
    for(int j=0;j+1<k;j++)
                ^
stove.java:17: error: class, interface, or enum expected
    for(int j=0;j+1<k;j++)
                      ^
stove.java:19: error: class, interface, or enum expected
    suma+=k;
    ^
stove.java:20: error: class, interface, or enum expected
    suma-=v[1];
    ^
stove.java:21: error: class, interface, or enum expected
    suma+=v[n];
    ^
stove.java:22: error: class, interface, or enum expected
    cout<<suma;
    ^
stove.java:23: error: class, interface, or enum expected
    return 0;
    ^
stove.java:24: error: class, interface, or enum expected
}
^
24 errors