Submission #1073924

#TimeUsernameProblemLanguageResultExecution timeMemory
1073924NoLoveCake 3 (JOI19_cake3)C++14
24 / 100
4003 ms9808 KiB
/** * author : Lăng Trọng Đạt * created: 2024-08-25 **/ #include <bits/stdc++.h> using namespace std; #ifndef LANG_DAT #define db(...) ; #endif // LANG_DAT #define int long long #define mp make_pair #define f first #define se second #define pb push_back #define all(v) (v).begin(), (v).end() using pii = pair<int, int>; using vi = vector<int>; #define FOR(i, a, b) for (int i = a; (i) <= (b); i++) void mx(int& a, int b) { if (b > a) a = b; } void mi(int& a, int b) { if (b < a) a = b; } #define si(x) (int)(x.size()) const int INF = 1e18; const int MOD = 1e9 + 7; const int N = 2e5 + 5; int g[N]; int n, m, k, a, b; int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("hi.inp", "r")) { freopen("hi.inp", "r", stdin); // freopen("hi.out", "w", stdout); } cin >> n >> m; vector<pii> p(n); for (auto&[c, v] : p) cin >> v >> c; sort(all(p)); int ans = -INF; db(p) FOR(i, 0, n - 1) { db(p[i]) if (i + m > n) break; int total = p[i].se; multiset<int> val; for (int j = i + 1; j < i + m - 1; j++) { val.insert(p[j].se); total += p[j].se; } db(i, i + m -1) db(val, total) for (int j = i + m - 1; j < n; j++) { val.insert(p[j].se); total += p[j].se; mx(ans, total - 2*(p[j].f - p[i].f)); db(j, total, p[j], ans) total -= *val.begin(); val.erase(val.begin()); } } cout << ans; }

Compilation message (stderr)

cake3.cpp: In function 'int32_t main()':
cake3.cpp:38:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |     for (auto&[c, v] : p) cin >> v >> c;
      |               ^
cake3.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...