# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868907 | 2023-11-02T12:25:19 Z | rockstar | Stove (JOI18_stove) | C++17 | Compilation error |
0 ms | 0 KB |
// #pragma GCC optimize("O3,unroll-loops,inline,no-stack-protector") // #pragma GCC target("avx,avx2,sse3,ssse3,sse4.1,sse4.2,fma,bmi2,abm,popcnt,mmx,tune=native") #include <bits/stdc++.h> using namespace std; #define trace(x) cerr << #x << ": " << (x) << endl; #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() using ll = long long; #define int ll constexpr int INF = numeric_limits<int>::max() / 2; void solve() { int n, k; cin >> n >> k; vector<int> t(n); for (int& i : t) cin >> i; vector<int> diff(n - 1); for (int i = 1; i < n; ++i) diff[i - 1] = t[i] - t[i - 1]; sort(all(diff)); int ans = 0; for (int i = 0; i <= n - 1 - k; ++i) ans += diff[i]; cout << ans + k; } signed main() { #ifdef LOCAL freopen("input.in", "r", stdin); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif int t = 1; // cin >> t; while (t--) solve(); #ifdef LOCAL cerr << '\n' << "time = " << clock() * 1.0 / CLOCKS_PER_SEC << '\n'; #endif return 0; }
Compilation message
stove.cpp:3:1: error: extended character is not valid in an identifier 3 | | ^ stove.cpp:5:1: error: extended character is not valid in an identifier 5 | | ^ stove.cpp:7:1: error: extended character is not valid in an identifier 7 | | ^ stove.cpp:11:1: error: extended character is not valid in an identifier 11 | | ^ stove.cpp:13:1: error: extended character is not valid in an identifier 13 | | ^ stove.cpp:15:1: error: extended character is not valid in an identifier 15 | | ^ stove.cpp:17:1: error: extended character is not valid in an identifier 17 | | ^ stove.cpp:19:1: error: extended character is not valid in an identifier 19 | int n, k; | ^ stove.cpp:19:1: error: extended character is not valid in an identifier stove.cpp:19:1: error: extended character is not valid in an identifier stove.cpp:19:1: error: extended character is not valid in an identifier stove.cpp:20:1: error: extended character is not valid in an identifier 20 | cin >> n >> k; | ^ stove.cpp:20:1: error: extended character is not valid in an identifier stove.cpp:20:1: error: extended character is not valid in an identifier stove.cpp:20:1: error: extended character is not valid in an identifier stove.cpp:21:1: error: extended character is not valid in an identifier 21 | vector<int> t(n); | ^ stove.cpp:21:1: error: extended character is not valid in an identifier stove.cpp:21:1: error: extended character is not valid in an identifier stove.cpp:21:1: error: extended character is not valid in an identifier stove.cpp:22:1: error: extended character is not valid in an identifier 22 | for (int& i : t) | ^ stove.cpp:22:1: error: extended character is not valid in an identifier stove.cpp:22:1: error: extended character is not valid in an identifier stove.cpp:22:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier 23 | cin >> i; | ^ stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:23:1: error: extended character is not valid in an identifier stove.cpp:24:1: error: extended character is not valid in an identifier 24 | vector<int> diff(n - 1); | ^ stove.cpp:24:1: error: extended character is not valid in an identifier stove.cpp:24:1: error: extended character is not valid in an identifier stove.cpp:24:1: error: extended character is not valid in an identifier stove.cpp:25:1: error: extended character is not valid in an identifier 25 | for (int i = 1; i < n; ++i) | ^ stove.cpp:25:1: error: extended character is not valid in an identifier stove.cpp:25:1: error: extended character is not valid in an identifier stove.cpp:25:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier 26 | diff[i - 1] = t[i] - t[i - 1]; | ^ stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:26:1: error: extended character is not valid in an identifier stove.cpp:27:1: error: extended character is not valid in an identifier 27 | sort(all(diff)); | ^ stove.cpp:27:1: error: extended character is not valid in an identifier stove.cpp:27:1: error: extended character is not valid in an identifier stove.cpp:27:1: error: extended character is not valid in an identifier stove.cpp:28:1: error: extended character is not valid in an identifier 28 | int ans = 0; | ^ stove.cpp:28:1: error: extended character is not valid in an identifier stove.cpp:28:1: error: extended character is not valid in an identifier stove.cpp:28:1: error: extended character is not valid in an identifier stove.cpp:29:1: error: extended character is not valid in an identifier 29 | for (int i = 0; i <= n - 1 - k; ++i) | ^ stove.cpp:29:1: error: extended character is not valid in an identifier stove.cpp:29:1: error: extended character is not valid in an identifier stove.cpp:29:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier 30 | ans += diff[i]; | ^ stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:30:1: error: extended character is not valid in an identifier stove.cpp:31:1: error: extended character is not valid in an identifier 31 | cout << ans + k; | ^ stove.cpp:31:1: error: extended character is not valid in an identifier stove.cpp:31:1: error: extended character is not valid in an identifier stove.cpp:31:1: error: extended character is not valid in an identifier stove.cpp:33:1: error: extended character is not valid in an identifier 33 | | ^ stove.cpp:36:1: error: extended character is not valid in an identifier 36 | freopen("input.in", "r", stdin); | ^ stove.cpp:36:1: error: extended character is not valid in an identifier stove.cpp:36:1: error: extended character is not valid in an identifier stove.cpp:36:1: error: extended character is not valid in an identifier stove.cpp:38:1: error: extended character is not valid in an identifier 38 | ios_base::sync_with_stdio(false); | ^ stove.cpp:38:1: error: extended character is not valid in an identifier stove.cpp:38:1: error: extended character is not valid in an identifier stove.cpp:38:1: error: extended character is not valid in an identifier stove.cpp:39:1: error: extended character is not valid in an identifier 39 | cin.tie(nullptr); | ^ stove.cpp:39:1: error: extended character is not valid in an identifier stove.cpp:39:1: error: extended character is not valid in an identifier stove.cpp:39:1: error: extended character is not valid in an identifier stove.cpp:41:1: error: extended character is not valid in an identifier 41 | int t = 1; | ^ stove.cpp:41:1: error: extended character is not valid in an identifier stove.cpp:41:1: error: extended character is not valid in an identifier stove.cpp:41:1: error: extended character is not valid in an identifier stove.cpp:42:1: error: extended character is not valid in an identifier 42 | // cin >> t; | ^ stove.cpp:42:1: error: extended character is not valid in an identifier stove.cpp:42:1: error: extended character is not valid in an identifier stove.cpp:42:1: error: extended character is not valid in an identifier stove.cpp:43:1: error: extended character is not valid in an identifier 43 | while (t--) | ^ stove.cpp:43:1: error: extended character is not valid in an identifier stove.cpp:43:1: error: extended character is not valid in an identifier stove.cpp:43:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier 44 | solve(); | ^ stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:44:1: error: extended character is not valid in an identifier stove.cpp:46:1: error: extended character is not valid in an identifier 46 | cerr << '\n' << "time = " << clock() * 1.0 / CLOCKS_PER_SEC << '\n'; | ^ stove.cpp:46:1: error: extended character is not valid in an identifier stove.cpp:46:1: error: extended character is not valid in an identifier stove.cpp:46:1: error: extended character is not valid in an identifier stove.cpp:48:1: error: extended character is not valid in an identifier 48 | return 0; | ^ stove.cpp:48:1: error: extended character is not valid in an identifier stove.cpp:48:1: error: extended character is not valid in an identifier stove.cpp:48:1: error: extended character is not valid in an identifier stove.cpp:3:1: error: '\U000000a0' does not name a type 3 | | ^ In file included from /usr/include/c++/10/cmath:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/include/c++/10/ext/type_traits.h:162:35: error: 'bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 162 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/10/ext/type_traits.h:157:5: note: previous declaration 'template<class _Type> bool __gnu_cxx::__is_null_pointer(_Type)' 157 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/10/ext/type_traits.h:162:26: error: 'nullptr_t' is not a member of 'std' 162 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/10/bits/move.h:57, from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/include/c++/10/type_traits:402:26: error: 'std::size_t' has not been declared 402 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/10/type_traits:403:25: error: '_Size' was not declared in this scope 403 | struct is_array<_Tp[_Size]> | ^~~~~ /usr/include/c++/10/type_traits:403:31: error: template argument 1 is invalid 403 | struct is_array<_Tp[_Size]> | ^ /usr/include/c++/10/type_traits:508:42: error: 'nullptr_t' is not a member of 'std' 508 | struct __is_null_pointer_helper<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/10/type_traits:508:51: error: template argument 1 is invalid 508 | struct __is_null_pointer_helper<std::nullptr_t> | ^ /usr/include/c++/10/type_traits:1351:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1351 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/10/bits/std_abs.h:38, from /usr/include/c++/10/cmath:47, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/10/bits/move.h:57, from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/include/c++/10/type_traits:1351:57: error: template argument 1 is invalid 1351 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/10/type_traits:1351:57: note: invalid template non-type parameter /usr/include/c++/10/type_traits:1360:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1360 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/10/bits/std_abs.h:38, from /usr/include/c++/10/cmath:47, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/10/bits/move.h:57, from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/include/c++/10/type_traits:1360:46: error: template argument 1 is invalid 1360 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/10/type_traits:1360:46: note: invalid template non-type parameter /usr/include/c++/10/type_traits:1362:26: error: 'std::size_t' has not been declared 1362 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/10/type_traits:1363:21: error: '_Size' was not declared in this scope 1363 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/10/type_traits:1363:27: error: template argument 1 is invalid 1363 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/10/type_traits:1364:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1364 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/10/bits/std_abs.h:38, from /usr/include/c++/10/cmath:47, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h:209:23: note: 'size_t' declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/10/bits/move.h:57, from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from stove.cpp:4: /usr/include/c++/10/type_traits:1364:65: error: template argument 1 is invalid 1364 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/10/type_traits:1364:65: note: invalid template non-type parameter /usr/include/c++/10/type_traits:1368:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 13