Submission #1105291

#TimeUsernameProblemLanguageResultExecution timeMemory
1105291Lakshya108Cloud Computing (CEOI18_clo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // Macros #define pb push_back #define pf push_front #define ff first #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define up(v) upper_bound(v) #define low(v) lower_bound(v) // Read and Print #define read(a, n) for(ll i = 0; i < n; ++i) cin >> a[i]; #define print(a, n) for(ll i = 0; i < n; ++i){ cout << a[i] << " ";} cout << "\n"; #define endl "\n" #define sp " " // Typedefs typedef long long ll; typedef long double ld; typedef long long int lli; typedef pair<ll, ll> pll; typedef pair<lli, lli> plli; typedef pair<int, int> pii typedef vector<lli> vi; typedef vector<vector<lli>> vvi; using vec = vector<int>; // Constants const ll mxn = 1e6 + 5; const ll mod = 1e9 + 7; // Solve const ll N = 1e5 + 5; void solve(){ ll n; cin >> n; vi c(n), f(n), v(n); vector<tuple<ll, ll, ll>> a; ll sum = 0; for(ll i = 0; i < n; i++){ cin >> c[i] >> f[i] >> v[i]; a.pb({f[i], c[i], -v[i]}); sum += c[i]; } ll m; cin >> m; vector<ll> C(m), F(m), V(m); for(ll i = 0; i < m; i++){ cin >> C[i] >> F[i] >> V[i]; a.pb({F[i], C[i], V[i]}); } sort(rall(a)); vi dp(sum + 1, -mod); dp[0] = 0; for(auto [i, j, k] : a){ if(k > 0){ for(ll l = j; l <= sum; l++){ dp[l - j] = max(dp[l - j], dp[l] + k); } } else { for(ll l = sum - j; l >= 0; l--){ dp[l + j] = max(dp[l + j], dp[l] + k); } } } sort(rall(dp)); cout << dp[0] << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }

Compilation message (stderr)

clo.cpp:27:1: error: expected initializer before 'typedef'
   27 | typedef vector<lli> vi;
      | ^~~~~~~
clo.cpp: In function 'void solve()':
clo.cpp:41:5: error: 'vi' was not declared in this scope; did you mean 'vvi'?
   41 |     vi c(n), f(n), v(n);
      |     ^~
      |     vvi
clo.cpp:45:16: error: 'c' was not declared in this scope
   45 |         cin >> c[i] >> f[i] >> v[i];
      |                ^
clo.cpp:45:24: error: 'f' was not declared in this scope
   45 |         cin >> c[i] >> f[i] >> v[i];
      |                        ^
clo.cpp:45:32: error: 'v' was not declared in this scope
   45 |         cin >> c[i] >> f[i] >> v[i];
      |                                ^
clo.cpp:46:33: error: no matching function for call to 'std::vector<std::tuple<long long int, long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   46 |         a.pb({f[i], c[i], -v[i]});
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<long long int, long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<long long int, long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::tuple<long long int, long long int, long long int> >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
clo.cpp:57:7: error: expected ';' before 'dp'
   57 |     vi dp(sum + 1, -mod);
      |       ^~~
      |       ;
clo.cpp:58:5: error: 'dp' was not declared in this scope; did you mean 'sp'?
   58 |     dp[0] = 0;
      |     ^~
      |     sp
clo.cpp:59:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   59 |     for(auto [i, j, k] : a){
      |              ^