Submission #654093

#TimeUsernameProblemLanguageResultExecution timeMemory
654093sofija6Zalmoxis (BOI18_zalmoxis)C++14
35 / 100
866 ms112120 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 1000010 using namespace std; map<ll,vector<ll> > m; ll a[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,k,x; cin >> n >> k; priority_queue<pair<ll,pair<ll,ll> >,vector<pair<ll,pair<ll,ll> > >,greater<pair<ll,pair<ll,ll> > > > q; for (ll i=1;i<=n;i++) { cin >> a[i]; q.push({a[i],{i,i}}); } while (true) { auto t=q.top(); q.pop(); if (q.empty()) { x=t.first; break; } if (q.top().first!=t.first || q.top().second.first!=t.second.second+1) { m[t.second.second].push_back(t.first); t.first++; q.push(t); k--; continue; } t.second.second=q.top().second.second; q.pop(); t.first++; q.push(t); } for (ll i=1;i<=n;i++) { cout << a[i] << " "; for (ll j=0;j<m[i].size();j++) cout << m[i][j] << " "; } while (k--) { cout << x << " "; x++; } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:43:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (ll j=0;j<m[i].size();j++)
      |                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...