Submission #212123

#TimeUsernameProblemLanguageResultExecution timeMemory
212123NONAMEHolding (COCI20_holding)C++17
22 / 110
126 ms262148 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #define F first #define S second #define pb push_back #define N 110 * 110 #define M ll(1e9 + 7) #define sz(x) (int)x.size() #define re return #define oo ll(1e18) #define el '\n' using namespace std; //using namespace __gnu_pbds; //typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef long long ll; typedef long double ld; int ans = 1e9, l, r, i, j, msk, n, k, a[N], sm, p, sum, le, ri, t, nt; int f[N][110][110]; vector <pair <int, int> > v, v1; int main() { // srand(time(0)); ios_base::sync_with_stdio(0); iostream::sync_with_stdio(0); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); // in("input.txt"); // out("output.txt"); cin >> n >> l >> r >> k; for (i = 1; i <= n; i++) cin >> a[i]; for (i = l; i <= r; i++) sm += a[i], v.pb({a[i], i}); for (i = 1; i < l; i++) v1.pb({a[i], i}); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); sort(v1.begin(), v1.end()); for (int cost = 0; cost <= k; cost++) for (i = 0; i <= n + 1; i++) for (j = 0; j <= n + 1; j++) f[cost][i][j] = 1e9; f[0][0][0] = sm; for (t = 0; t < v.size(); t++) for (sum = 0; sum <= k; sum++) for (le = 0; le < v1.size(); le++) { if (f[sum][le][t] == 1e9) continue; for (i = le + 1; i <= v1.size(); i++) for (nt = t + 1; nt <= v.size(); nt++) { if (abs(v1[i - 1].S - v[nt - 1].S) + sum <= k) f[sum + abs(v1[i - 1].S - v[nt - 1].S)][i][nt] = min(f[sum + abs(v1[i - 1].S - v[nt - 1].S)][i][nt], f[sum][le][t] + v1[i - 1].F - v[nt - 1].F); } } for (int cost = 0; cost <= k; cost++) for (i = 0; i <= n + 1; i++) for (j = 0; j <= n + 1; j++) ans = min(ans, f[cost][i][j]); cout << ans; }

Compilation message (stderr)

holding.cpp: In function 'int main()':
holding.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (t = 0; t < v.size(); t++)
                 ~~^~~~~~~~~~
holding.cpp:51:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (le = 0; le < v1.size(); le++)
                          ~~~^~~~~~~~~~~
holding.cpp:54:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (i = le + 1; i <= v1.size(); i++)
                              ~~^~~~~~~~~~~~
holding.cpp:55:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                for (nt = t + 1; nt <= v.size(); nt++)
                                 ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...