답안 #64509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64509 2018-08-04T17:07:45 Z mirbek01 Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
331 ms 11256 KB
# 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

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]);
             ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 274 ms 6356 KB Output is correct
2 Correct 226 ms 6520 KB Output is correct
3 Correct 273 ms 6520 KB Output is correct
4 Correct 296 ms 6584 KB Output is correct
5 Correct 225 ms 6584 KB Output is correct
6 Correct 256 ms 6584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 234 ms 6616 KB Unexpected end of file - int32 expected
2 Correct 241 ms 6620 KB Output is correct
3 Runtime error 152 ms 8620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 263 ms 10660 KB Unexpected end of file - int32 expected
5 Incorrect 331 ms 10772 KB Unexpected end of file - int32 expected
6 Incorrect 276 ms 10772 KB Unexpected end of file - int32 expected
7 Incorrect 286 ms 10772 KB Unexpected end of file - int32 expected
8 Incorrect 284 ms 10904 KB Unexpected end of file - int32 expected
9 Incorrect 220 ms 11256 KB Unexpected end of file - int32 expected
10 Incorrect 138 ms 11256 KB Unexpected end of file - int32 expected
11 Incorrect 221 ms 11256 KB Unexpected end of file - int32 expected
12 Runtime error 21 ms 11256 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 16 ms 11256 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 16 ms 11256 KB Execution killed with signal 11 (could be triggered by violating memory limits)