Submission #315347

# Submission time Handle Problem Language Result Execution time Memory
315347 2020-10-22T14:51:29 Z Dymo Stove (JOI18_stove) C++14
100 / 100
25 ms 3324 KB
#include<bits/stdc++.h>

using namespace std;


#define pb	push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=5e5+50;
const ll mod =1e9+7;
const ll base=113;
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("GIDDY.inp", "r"))
    {
        freopen("GIDDY.inp", "r", stdin);
        freopen("GIDDY.out", "w", stdout) ;
    }
    ll n, k ;
     cin>>n>>k ;
     for (int i=1;i<=n;i++)
     {
         cin>>a[i];
     }
     ll ans=n;
     sort(a+1,a+n+1);
     vector<ll> ans1;
     for (int i=2;i<=n;i++)
     {
         ans1.pb(a[i]-a[i-1]-1);

     }
     sort(ans1.begin(),ans1.end());
     for (auto to:ans1)
     {
         if (k==n) break;
         ans+=to;
         k++;

     }
     cout <<ans;


}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         freopen("GIDDY.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         freopen("GIDDY.out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 23 ms 3068 KB Output is correct
17 Correct 23 ms 3068 KB Output is correct
18 Correct 23 ms 3068 KB Output is correct
19 Correct 23 ms 3068 KB Output is correct
20 Correct 23 ms 3068 KB Output is correct
21 Correct 23 ms 3196 KB Output is correct
22 Correct 23 ms 3060 KB Output is correct
23 Correct 25 ms 3068 KB Output is correct
24 Correct 23 ms 3324 KB Output is correct