Submission #64509

#TimeUsernameProblemLanguageResultExecution timeMemory
64509mirbek01Zalmoxis (BOI18_zalmoxis)C++17
35 / 100
331 ms11256 KiB
# include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; int n, k, a[N]; deque <int> dq; vector < pair <int, int> > vec; int main(){ scanf("%d %d", &n, &k); for(int i = 1; i <= n; i ++) scanf("%d", &a[i]); dq.push_back(30); int id = 1; while(id <= n){ int v = dq.front(); dq.pop_front(); if(v == a[id]){ id ++; } else if(v < a[id]){ vec.push_back({id - 1, v}); } else { v --; if(v < 0) continue; dq.push_front(v); dq.push_front(v); } } for(int i = 0; i < dq.size(); i ++) vec.push_back({id - 1, dq[i]}); k -= vec.size(); int pos = 0; for(int i = 1; i <= n; i ++){ cout << a[i] << " "; while(pos < vec.size() && vec[pos].first <= i){ vector <int> vv; dq.clear(); dq.push_back(vec[pos ++].second); while(k > 0){ int v = dq.front(); dq.pop_front(); v --; if(v > 0){ dq.push_front(v); dq.push_front(v); } else vv.push_back(0); k --; } for(int j = 0; j < dq.size(); j ++) vv.push_back(dq[j]); for(int j = 0; j < vv.size(); j ++) cout << vv[j] << " "; } } while(pos < vec.size()){ vector <int> vv; dq.clear(); dq.push_back(vec[pos ++].second); while(k > 0){ int v = dq.front(); dq.pop_front(); v --; if(v > 0){ dq.push_front(v); dq.push_front(v); } else vv.push_back(0); k --; } for(int j = 0; j < dq.size(); j ++) vv.push_back(dq[j]); for(int j = 0; j < vv.size(); j ++) cout << vv[j] << " "; } } /** 8 2 28 27 26 25 25 25 25 28 **/

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:36:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i < dq.size(); i ++)
                      ~~^~~~~~~~~~~
zalmoxis.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(pos < vec.size() && vec[pos].first <= i){
                   ~~~~^~~~~~~~~~~~
zalmoxis.cpp:59:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   for(int j = 0; j < dq.size(); j ++)
                                  ~~^~~~~~~~~~~
zalmoxis.cpp:61:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   for(int j = 0; j < vv.size(); j ++)
                                  ~~^~~~~~~~~~~
zalmoxis.cpp:65:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while(pos < vec.size()){
             ~~~~^~~~~~~~~~~~
zalmoxis.cpp:80:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0; j < dq.size(); j ++)
                            ~~^~~~~~~~~~~
zalmoxis.cpp:82:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0; j < vv.size(); j ++)
                            ~~^~~~~~~~~~~
zalmoxis.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d %d", &n, &k);
       ~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i]);
             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...