Submission #843565

#TimeUsernameProblemLanguageResultExecution timeMemory
843565CookieConstellation 3 (JOI20_constellation3)C++14
0 / 100
1 ms6492 KiB
#include<bits/stdc++.h> #include<fstream> #pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2") using namespace std; //ifstream fin("FEEDING.INP"); //ofstream fout("FEEDING.OUT"); #define sz(a) (int)a.size() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const int mxn = 2505; const ll inf = 1e18, mod = 1e9 + 7; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m; vt<pll>comp[mxn + 1]; ll a[mxn + 1], dp[2005][2005]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++)cin >> a[i]; cin >> m; ll cost = 0; for(int i = 0; i < m; i++){ int x, y, c; cin >> x >> y >> c; cost += c; comp[x].pb({y, c}); } ll res = 0; for(int i = 0; i < sz(comp[1]); i++){ dp[1][i] = comp[1][i].se; res = max(res, dp[1][i]); } for(int i = 2; i <= n; i++){ int idd = 0; for(auto [y, v]: comp[i]){ dp[i][idd] = v; ll mx = a[i]; for(int j = i - 1; j >= 1; j--){ mx = max(mx, a[j]); for(int k = 0; k < sz(comp[j]); k++){ if(comp[j][k].first <= mx || y <= mx){ dp[i][idd] = max(dp[i][idd], dp[j][k] + v); } } } res = max(res, dp[i][idd]); idd++; } } cout << cost - res; return(0); }

Compilation message (stderr)

constellation3.cpp: In function 'int main()':
constellation3.cpp:48:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   48 |         for(auto [y, v]: comp[i]){
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...