Submission #67525431
Source Code Expand
// 期待外れでいたいだなんて
// いつから願ってしまった?
// 名も知れぬほうがいいなんて
// いつからか願ってしまった
// ココロもネジ巻出して
// 意味を失ってしまった
// 何ひとつも動かせない今日と
// 押しつぶすように広がる
// 澄んだ機械仕掛けの空
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// Pragmas
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// Namespaces
using namespace std;
using namespace __gnu_pbds;
// Data types
using si = short int;
using ll = long long;
using ull = unsigned long long;
using lll = __int128;
using ld = long double;
// Pairs
using pii = pair<int, int>;
using psi = pair<si, si>;
using pll = pair<ll, ll>;
using plll = pair<lll, lll>;
using pld = pair<ld, ld>;
#define fi first
#define se second
// PBDS
template<typename Z>
using ordered_set = tree<Z, null_type, less<Z>, rb_tree_tag, tree_order_statistics_node_update>;
// Various outputs and debug
template<typename Z, typename = void> struct is_iterable : false_type {};
template<typename Z> struct is_iterable<Z, void_t<decltype(begin(declval<Z>())),decltype(end(declval<Z>()))>> : true_type {};
template<typename Z> typename enable_if<is_iterable<Z>::value&&!is_same<Z, string>::value,ostream&>::type operator<<(ostream &os, const Z &v);
template<typename Y, typename Z> ostream& operator<<(ostream &os, const pair<Y, Z> &p) {
return os << "(" << p.fi << ", " << p.se << ")";
}
template<class TupType, size_t... I> void printTuple(ostream& os, const TupType& _tup, index_sequence<I...>) {
os << "(";
(..., (os << (I == 0? "" : ", ") << get<I>(_tup)));
os << ")";
}
template<class... Z> ostream& operator<<(ostream& os, const tuple<Z...>& _tup) {
printTuple(os, _tup, make_index_sequence<sizeof...(Z)>());
return os;
}
template<typename Z> typename enable_if<is_iterable<Z>::value&&!is_same<Z, string>::value,ostream&>::type operator<<(ostream &os, const Z &v) {
os << "[";
for (auto it = v.begin(); it != v.end();) { os << *it; if (++it != v.end()) os << ", "; }
return os << "]";
}
#define debug(...) logger(cout, #__VA_ARGS__, __VA_ARGS__)
#define debugV(v, x) vlogger(cout, #v, x, v[x]);
#define rrebug(...) logger(cerr, #__VA_ARGS__, __VA_ARGS__)
#define rrebugV(v, x) vlogger(cerr, #v, x, v[x]);
template <typename... Args>
void logger(ostream& os, string vars, Args &&...values) {
os << vars << " = "; string delim = "";
(..., (os << delim << values, delim = ", "));
os << "\n";
}
template<class Y, class Z>
void vlogger(ostream& os, string var, Y idx, Z val) {
os << var << "[" << idx << "] = " << val << "\n";
}
// Various macros
#define All(x) x.begin(), x.end()
#define Sort(x) sort(All(x))
#define Reverse(x) reverse(All(x))
#define Uniqueify(x) Sort(x); x.erase(unique(All(x)), x.end())
#define RandomSeed chrono::steady_clock::now().time_since_epoch().count()
#define MultipleTestcases int _tc; cin >> _tc; for (int _cur_tc = 1; _cur_tc <= _tc; _cur_tc++)
// Chmin & chmax
template<typename Z> bool chmin(Z &a, Z b) { return (b < a) ? a = b, true : false; }
template<typename Z> bool chmax(Z &a, Z b) { return (b > a) ? a = b, true : false; }
// Modular arithmetic
template<int MOD>
class ModInt {
public:
int v;
ModInt() : v(0) {}
ModInt(long long _v) {
v = int((-MOD < _v && _v < MOD) ? (_v) : (_v % MOD));
if (v < 0) v += MOD;
}
friend bool operator==(const ModInt &a, const ModInt &b) { return a.v == b.v; }
friend bool operator!=(const ModInt &a, const ModInt &b) { return a.v != b.v; }
friend bool operator< (const ModInt &a, const ModInt &b) { return a.v < b.v; }
friend bool operator<=(const ModInt &a, const ModInt &b) { return a.v <= b.v; }
friend bool operator> (const ModInt &a, const ModInt &b) { return a.v > b.v; }
friend bool operator>=(const ModInt &a, const ModInt &b) { return a.v >= b.v; }
ModInt &operator+=(const ModInt &a) { v = (long long)(v + a.v) % MOD; return *this; }
ModInt &operator-=(const ModInt &a) { v = (long long)(v - a.v + MOD) % MOD; return *this; }
ModInt &operator*=(const ModInt &a) { v = 1ll * v * a.v % MOD; return *this; }
ModInt &operator/=(const ModInt &a) { return (*this) *= inverse(a); }
friend ModInt pow(ModInt a, long long x) {
ModInt res = 1;
for (; x; x /= 2, a *= a) if (x & 1) res *= a;
return res;
}
friend ModInt inverse(ModInt a) { return pow(a, MOD - 2); }
ModInt operator+ () const { return ModInt( v); }
ModInt operator- () const { return ModInt(-v); }
ModInt operator++() const { return *this += 1; }
ModInt operator--() const { return *this -= 1; }
friend ModInt operator+(ModInt a, const ModInt &b) { return a += b; }
friend ModInt operator-(ModInt a, const ModInt &b) { return a -= b; }
friend ModInt operator*(ModInt a, const ModInt &b) { return a *= b; }
friend ModInt operator/(ModInt a, const ModInt &b) { return a /= b; }
friend istream &operator>>(istream &is, ModInt &v) { return is >> v.v; }
friend ostream &operator<<(ostream &os, const ModInt &v) { return os << v.v; }
};
const int ModA = 998244353;
const int ModC = 1e9 + 7;
using MintA = ModInt<ModA>;
using MintC = ModInt<ModC>;
// Other constants
const ll INF = 1e18;
const ll iINF = 1e9;
const ld EPS = 1e-9;
const ld iEPS = 1e-6;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<ll> x(n);
for (auto &i : x) cin >> i;
Sort(x);
vector<ll> d;
for (int i = 0; i < n-1; i++) d.push_back(x[i+1] - x[i]);
Sort(d);
int take = n - m;
ll ans = accumulate(d.begin(), d.begin() + take, 0ll);
cout << ans << "\n";
}
// dibisakan
Submission Info
Submission Time |
|
Task |
D - Transmission Mission |
User |
Zanite |
Language |
C++ 20 (gcc 12.2) |
Score |
400 |
Code Size |
6176 Byte |
Status |
AC |
Exec Time |
100 ms |
Memory |
11300 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
All |
00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt |
Case Name |
Status |
Exec Time |
Memory |
00-sample-01.txt |
AC |
1 ms |
3520 KiB |
00-sample-02.txt |
AC |
1 ms |
3620 KiB |
00-sample-03.txt |
AC |
1 ms |
3512 KiB |
01-01.txt |
AC |
1 ms |
3556 KiB |
01-02.txt |
AC |
1 ms |
3548 KiB |
01-03.txt |
AC |
1 ms |
3508 KiB |
01-04.txt |
AC |
1 ms |
3424 KiB |
01-05.txt |
AC |
1 ms |
3516 KiB |
01-06.txt |
AC |
1 ms |
3360 KiB |
01-07.txt |
AC |
44 ms |
11300 KiB |
01-08.txt |
AC |
43 ms |
11128 KiB |
01-09.txt |
AC |
75 ms |
11020 KiB |
01-10.txt |
AC |
56 ms |
10024 KiB |
01-11.txt |
AC |
78 ms |
11152 KiB |
01-12.txt |
AC |
53 ms |
9364 KiB |
01-13.txt |
AC |
100 ms |
11144 KiB |
01-14.txt |
AC |
63 ms |
9704 KiB |
01-15.txt |
AC |
78 ms |
11196 KiB |