Submission #1072147

#TimeUsernameProblemLanguageResultExecution timeMemory
1072147NeroZeinTricks of the Trade (CEOI23_trade)C++17
10 / 100
8079 ms3156 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> c(n), s(n); for (int i = 0; i < n; ++i) { cin >> c[i]; } for (int i = 0; i < n; ++i) { cin >> s[i]; } long long mx = -LLONG_MAX; for (int i = 0; i < n; ++i) { long long cost = 0; for (int j = i; j < n; ++j) { cost -= c[j]; multiset<int> se; long long biggest = 0; for (int kk = i; kk <= j; ++kk) { biggest += s[kk]; se.insert(s[kk]); if ((int) se.size() > k) { biggest -= *se.begin(); se.erase(se.begin()); } if (se.size() == k) { mx = max(mx, cost + biggest); } } } } vector<bool> ok(n); for (int i = 0; i < n; ++i) { long long cost = 0; for (int j = i; j < n; ++j) { cost -= c[j]; multiset<int> se; long long biggest = 0; for (int kk = i; kk <= j; ++kk) { biggest += s[kk]; se.insert(s[kk]); if ((int) se.size() > k) { biggest -= *se.begin(); se.erase(se.begin()); } } if (cost + biggest == mx && se.size() == k) { for (int kk = i; kk <= j; ++kk) { if (s[kk] >= *se.begin()) { ok[kk] = true; } } } } } cout << mx << '\n'; for (int i = 0; i < n; ++i) { cout << ok[i]; } }

Compilation message (stderr)

trade.cpp: In function 'int main()':
trade.cpp:28:19: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if (se.size() == k) {
      |         ~~~~~~~~~~^~~~
trade.cpp:49:42: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |    if (cost + biggest == mx && se.size() == k) {
      |                                ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...