Submission #1286618

#TimeUsernameProblemLanguageResultExecution timeMemory
1286618thuhienneZalmoxis (BOI18_zalmoxis)C++20
55 / 100
684 ms124004 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define re exit(0); #define thuhien "zalmosis" int n,k; vector <int> s; struct range { int val; vector <int> container; }; vector <range> arr,temp; multiset <int> a; multiset <int>::iterator it; int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); if (fopen(thuhien".inp","r")) { freopen(thuhien".inp","r",stdin); freopen(thuhien".out","w",stdout); } cin >> n >> k; arr.resize(n); for (int i = 0;i < n;i++) { int a;cin >> a; arr[i] = {a,{a}}; } for (int tt = 0;tt < 29;tt++) { temp.clear(); for (auto x : arr) { if (temp.size() && temp.back().val == tt && x.val == tt) { temp.back().val++; for (auto a : x.container) temp.back().container.push_back(a); } else temp.push_back(x); } arr.clear(); arr = temp; for (int i = 0;i < arr.size();i++) if (arr[i].val == tt) { arr[i].val++; arr[i].container.push_back(tt); k--; } } //bay gio chi con dung mot so 29 if (k) { a.insert(29); while (a.size() != k) { it = a.end();it--; a.insert(*it - 1);a.insert(*it - 1); a.erase(it); } } for (auto x : arr) for (auto y : x.container) cout << y << " "; if (k) { it = a.end();it--; for (;;it--) { cout << *it << " "; if (it == a.begin()) break; } } }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:25:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |                 freopen(thuhien".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
zalmoxis.cpp:26:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |                 freopen(thuhien".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...