Submission #1086007

#TimeUsernameProblemLanguageResultExecution timeMemory
1086007WendidiaskStove (JOI18_stove)C++14
100 / 100
35 ms3332 KiB
/* :---:--:--::::::--:-:----: ::-:::. ::-::: .* -===.. :--- .-+*##=-------====-: :--: :+##=.* -= :=+- .-=: .+++-. :- -=. .=+- .--. .++=- + -= :*- :-. +*+- :- -=. -*: :=: #*: * -=. +- .= =:%+ -: -=. +- -- -%: * -=. *: +. :%-.. =. -=. # -: :=# .. + -=. == -= ---+ . = -=. .# .+ -: == . = :------::------:.-=. % .= :- == .=. ---:. :--#+. .% :- = .* .+.. :=- :++ -+ =: + #. + -=: :*%-*: * := :# :=:= . :-----: =+-+ .+ * -* *=- . .- :::::::. :* .#+. + :- -+ :#. --::-----: :* ++= .- + :*. *. .:::::*%: ++ +.-=. + + -#**----: .= -*. + -= = * +.#=+: + . .=+: =. -=. = = -+ :++: + .. .=+= .= -=. - = %- :====-:. =. .:--===- * -=. - + +-- .:--==#==-:.= + -=. = * + * =. : .= -=. = + = * + = -=. + :- = .= =: = -=. .- * + =: * * -=. + :- .+ =- :- .+ -=. .+ * * := * := -= * = :- =: .- .=: -=. =: -: * .=- + .=- -= :- =: -: --: :- :--: -=. .= =:+ ----. * :---. -= .+ --=*----------------------=*+=--=+--=+*+------------------------------------------------%+:. :: := +:- -- :. .=. =. -= -= .=: .=. .=: .+: :-- :-: -- -=. :--. --: :--: .--: .-:-: ::--. :----. .:---- .:::::::::-::::::--::::::::. */ #include <bits/stdc++.h> using namespace std; #define int long long #define debug(x) cerr << #x << " is " << x << "\n" #define hehe ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define rep(i, a, b) for (int i = a; i <= b; i++) #define repb(i, a, b) for (int i = b; i >= a; i--) #define pii pair<int, int> #define linebreak cout << "---------------------------------------------------------\n" #define f first #define s second #define pb push_back // good luck #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") const int MS = 2e5+5, mod = 1e9+7; int n, k, a[MS]; int32_t main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; int ans = a[n]-a[1]+1; vector<int> diff; for (int i = 1; i < n; i++) diff.pb(a[i+1]-a[i]-1); sort(diff.begin(), diff.end()); reverse(diff.begin(), diff.end()); for (int i = 0; i < k-1; i++) ans -= diff[i]; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...