Submission #1271754

#TimeUsernameProblemLanguageResultExecution timeMemory
1271754cbnk32_tuandungStove (JOI18_stove)C++17
100 / 100
13 ms1228 KiB
/* _ _ ___ __ ___ ___ _ _ ___ __ ___ _ _ ___ ___ __ _____ _ _ ___ */ /* | || | /_\ \ / / / __|/ _ \| \| |/ __| \ \ / /_\ | | | |/ _ \ / __| \ \ / / _ \| \| |/ __| */ /* | __ |/ _ \ V / \__ \ (_) | .` | (_ | \ V / _ \ | |_| | (_) | (__ \ V / (_) | .` | (_ | */ /* |_||_/_/_\_\_|___|___/\___/|_|\_|\___| \_/_/_\_\ _\___/ \___/ \___| _ \_/_\___/|_|\_|\___| ___ */ /* | \| __| |_ _| || | /_\ \ / / | \ / _ \_ _| | \/ | __| \| | || | | \/ |/ _ \| \| |/ __| */ /* | |) | _| | | | __ |/ _ \ V / | |) | (_) | | | |\/| | _|| .` | __ | | |\/| | (_) | .` | (_ | */ /* |___/|___| |_| |_||_/_/ \_\_| |___/ \___/___| |_| |_|___|_|\_|_||_| |_| |_|\___/|_|\_|\___| */ #include <bits/stdc++.h> using namespace std; /* run g++ JOI18_stove.cpp -o run.exe && ./run.exe g++ JOI18_stove.cpp -std=c++1y -o run.exe && ./run.exe */ #define re exit(0) #define r0 return 0 #define ll long long #define ull unsigned long long #define TASK "." typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vpii; constexpr int MOD = 1000000007; constexpr int MAX_N = 100000 + 5; template<typename T> void minimise(T &abc, T xyz) { if (abc > xyz) abc = xyz; } template<typename T> void maximise(T &abc, T xyz) { if (abc < xyz) abc = xyz; } template<typename T> void add(T &abc, T xyz) { abc += xyz; if (abc >= MOD) abc -= MOD; if (abc < 0) abc += MOD; } void fileIO() { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } int N, K; int A[MAX_N]; vi d; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); // fileIO(); cin >> N >> K; for (int i = 1; i <= N; ++i) { cin >> A[i]; } int res = N; for (int i = 2; i <= N; ++i) { d.push_back(A[i] - A[i - 1] - 1); } sort(d.begin(), d.end()); for (int i = 0; i < (N - K); ++i) { res += d[i]; } cout << res; cerr << "\nTime elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << " s."; r0; } /* Rubi-channnnn~~~ Haiiii~~~ Nani ga suki? Choco minto... yori mo anata~ Ayumu-channnnn~~~ Haiiiii~~~ Nani ga suki? Suturuberi fureiba yori mo anata~ Shiki-channnn~~~ Haiiiii~~~~ Nani ga suki? Kukkie ando krimu yori mo anata~ Minaaaa~~~ Haiiiiii~~~ Nani ga suki? Mochrion daisuki AI♡SCREAM */

Compilation message (stderr)

stove.cpp: In function 'void fileIO()':
stove.cpp:48:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     freopen(TASK".INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:49:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     freopen(TASK".OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...