Submission #959314

# Submission time Handle Problem Language Result Execution time Memory
959314 2024-04-08T00:24:41 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ii = pair<int,int>; using ll = long long; using ull = unsigned long long;
using vi = vector<int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
void test_case(){
    int n,k; cin >> n >> k;
    vi a(n);ll sum = 0;
    vi dis(n-1);
    fo(i,n){
        cin >> a[i];
        if(i>0)dis[i-1] = a[i] - a[i-1], sum+=dis[i-1];
    }
    sort(all(dis));
    forex(i,n-2, max(0, n-k))sum-=dis[i];
    cout << sum+k << endl;
}
int main(){cin.tie(0)->sync_with_stdio(0);
    int t=1;
    cin >> t;
    while(t--)test_case();
}

Compilation message

stove.cpp:20: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   20 | #pragma GCC optimization ("O3")
      | 
stove.cpp:21: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   21 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -