Submission #930971

#TimeUsernameProblemLanguageResultExecution timeMemory
930971lftroqStove (JOI18_stove)C++14
100 / 100
15 ms7768 KiB
/* :-=- :%@@@@@@@@@= .#@@@@@%@%@@@@@@= -@@@@@@@@@@@@@@@@@# .+@@@@@@@@@@@@@@@@@@@@. #@@@@@@@@@@@@@@@@@@@@@% .*@@@@@@@@@@@@@@@@@@@@@@@= / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\ .@@@@@@@@@@@@@@@@@@@@@@@@# | lftroq ♥ | +@@@@@@@@@@@%%@@@@@@@@@@@@- \_________/ .%@@@@@@@@@@%##%@@@@@@@@@@@# // -@@@@@@@@%%%%%%%%%@@@@@@@@@@: -+- =@@@@@%##%#%##**+#@@@@@@@@@@- .+++.%@@@%##%%%%%%%#**+##%%@@@@@@+ +=*%@@@#*###%%#=--+=+*##%@@@@@@%. :*+%@@*+**##*=======+***#@@@@@@@: =+++**%@###*=++=-==++**#@@@@@@@: .**===*%@@@##+=**#*==***@@@@@@@@@: :+++=+*+%%@@%#==+*%#*+=++@@@@@@@@% .**#*+*+**+%#+=---=***+==*@@@@@@@: :**#*+=+**@%##*%#++++--=++#@@@@@@@+-::. =%**###**#@@%*=*%%%%%*==++++%@@@@@@#=-----. .%@@%***###@@@%*++%%%#*===+=++++%@@@@%*=-----=. =**##+=+##@@@@=+%+=***#%@#+**++++%@@%+=-------=: .++===++====@@@@+--==-=#%%%%+++*++++#%+=------==+=. -++--=++-:::::=#@#----+--*%%*+**+++++++==-----===--+= :*+=--++-::::::--=-----==-=%==+%%***++=---=---===-=++: :*+--+=-::::::::---:----+=-=++##***===-::::-+----=*+: .=--:::.:::-=-::---::--------++--=====-::::--:-==++ :=::::::--::::::--=+-:--++++==++--==:::-:::----==+= *-:::::::.....:-++++++++++++++=+=---::::===-:------ :+:--:......:-+++++++++++++++++====---:--=-=----:-:=. :==--:::.:=+++++++++++++++++++++-::===-:-===-----=--: .+=--:::-:=+++++==++++++++++++++=--:.:-===+-------+=-. .+==-----::-+++-:+++=====+++++++=--=======--:----==+=. :+===-----------:-++====+++++++++=--==--+-:------==-:: +=====-::----+-::-+====+++++++++++=---==:-===:-==-==. :+===========+-::::-----+++++++++++*=--======-=+=-=. .=========++=-::::::----:::-++++++*+=+======+++==. .=========-::::::-----:::=+++++**+=+**====-:. . *======-::::::::-:-----++++++++==++++++- #======-:::::::::-------++++++++====+++= =======-:::::::::----:::=+++++++=====+++ =====---:::::::::::------=++++++===+==++= :===-:--:::::::::::-------+++++++===++=++ .===-:--:::::::::::::-----=+++++====++===. .+=-::--::::::::::::-:-----++++++====++=+: .=-:::--::::::::::::-------=+++++===-----+= .=-:::--:::::::::::---------=++++==-----==+=. .=-:::---:::::::::::---------+++===-----===++. .=::::---:::::::-:-----------=++==-:-----===+- .--:::---:::::::--------------=+=----==--===+- .=::::---::::::::::-------===--==-------=--==: .=--::--::::----:---:::::-:----:::-----======- .=---:--:::---::::::--------------------==++++ */ #include <bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MOD 1000000007LL #define MOD2 998244353LL #define endl '\n' #define PI acos(-1) #define INFINITE 2147483647LL #define INFINITE2 9223372036854775807 #define llll pair<ll,ll> #define ldld pair<ld,ld> #define fi first #define se second #define sqrt sqrtl typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; ll a[1000005],b[1000005]; void solve() { ll n,k; cin >> n >> k; for(int i=1;i<=n;i++) cin >> a[i]; for(int i=1;i<n;i++) b[i]=(a[i+1]-a[i]-1); sort(b+1,b+n,greater<int>()); ll ans=a[n]-a[1]+1; for(int i=1;i<k;i++) ans-=b[i]; cout << ans << endl; } int main() { fastIO //freopen("hanhhhh.inp","r",stdin); //freopen("hanhhhh.out","w",stdout); int t=1; //cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...