Submission #854343

# Submission time Handle Problem Language Result Execution time Memory
854343 2023-09-27T00:44:53 Z dungz Stove (JOI18_stove) C++17
0 / 100
2 ms 344 KB
#include<bits/stdc++.h>
#define ll long long
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define task "stove"
using namespace std;
const int N=1e5+5;
const ll oo=1e18;
const int base=311;
int n,k;
int a[N];
int ans;
vector<int>vec;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    cin>>n>>k;
    fo(i,1,n)cin>>a[i];
    ans=a[n]+1-a[1];
    fo(i,1,n-1)
    vec.emplace_back(a[i+1]-a[i]-1);
    sort(vec.begin(),vec.end());
    fod(i,vec.size()-1, 0)
    {
        if(k==1)break;
        ans-=vec[i];
        k--;
    }
    cout<<ans;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
stove.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -