Submission #336233

#TimeUsernameProblemLanguageResultExecution timeMemory
336233ttnhuy313Zalmoxis (BOI18_zalmoxis)C++14
100 / 100
235 ms29488 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair <int, int> ii; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; int rem = n + k, x; stack <int> s, cur; stack <ii> ans; for(int i = 0; i < n; i++){ cin >> x; s.push(x); } cur.push(30); while (!s.empty()){ if (cur.top() <= s.top()){ ans.push(ii(cur.top(), cur.top() == s.top())); if (s.top() == cur.top()) s.pop(); cur.pop(); } else{ int x = cur.top(); cur.pop(); cur.push(x - 1); cur.push(x - 1); } } while (!cur.empty()) { ans.push(ii(cur.top(),0)); cur.pop(); } vector <int> fans; while (rem > 0){ if (ans.size() == rem || ans.top().second == 1 || ans.top().first==0){ fans.push_back(ans.top().first); ans.pop(); rem--; } else{ x = ans.top().first; ans.pop(); ans.push(ii(x - 1,0)); ans.push(ii(x - 1,0)); } } for(int i = 0; i < n + k; i++){ cout << fans[i] << " "; } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:37:18: warning: comparison of integer expressions of different signedness: 'std::stack<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   37 |   if (ans.size() == rem || ans.top().second == 1 || ans.top().first==0){
      |       ~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...