제출 #63016

#제출 시각아이디문제언어결과실행 시간메모리
63016hamzqq9Zalmoxis (BOI18_zalmoxis)C++14
5 / 100
294 ms11496 KiB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define sz(x) (x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000500000
#define MOD 1000000007
#define N 305
#define LOG 20
using namespace std;

int n,k,x;
stack<int> s;
vector<int> ans;

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&k);

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		while(sz(s) && s.top()<x) {

			int val=s.top();

			ans.pb(val);

			while(sz(s) && s.top()==val) {

				s.pop();

				val++;

			}

			s.push(val);

		}

		int tut=x;

		while(sz(s) && s.top()==tut) {

			s.pop();

			tut++;

		}

		s.push(tut);

		ans.pb(x);

	}

	while(sz(ans)<k) {

		int val=s.top();
		s.pop();

		ans.pb(val);

		s.push(val+1);

	}

	for(auto x:ans) printf("%d ",x);

}

컴파일 시 표준 에러 (stderr) 메시지

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(sz(ans)<k) {
               ^
zalmoxis.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
zalmoxis.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...