답안 #64311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64311 2018-08-04T04:33:17 Z kylych03 Zalmoxis (BOI18_zalmoxis) C++14
15 / 100
150 ms 12088 KB
# include <bits/stdc++.h>

using namespace std;
vector < int > vec[100001];
int cnt=0;
void fun(int i,int j){
	if(cnt<=0)
	return;
	if(vec[i].size()<=j)
		return;
	if(vec[i][j]<=0)
	{
		fun(i,j+1);
		return;
	}
	
	vec[i][j]--;
	vec[i].insert(vec[i].begin()+j, vec[i][j]);
	cnt--;
	fun(i,j);
		
}
int main(){
	int n,k,i,a[100001];

	cin>>n>>k;
	
	for(i=0;i<n;i++)
		cin>>a[i];
	deque <int> dq;
	dq.push_back(30);
	i=0;
	while(i<n){
		if(dq.front() > a[i]){
			
			dq.front()--;
			dq.push_front(dq.front());
		}
		else
		if(dq.front()==a[i]){
			i++;
			dq.pop_front();
		}
		else
		if(dq.front() < a[i]){
			
			vec[i].push_back(dq.front());
			dq.pop_front();
			cnt++;
		}
	}
	while(dq.size()>0){
		vec[n].push_back(dq.front());
		dq.pop_front();
		cnt++;
	}
	
	cnt=k-cnt;
	
	
	for(i=0;i<=n;i++){
		
		if(cnt!=0 && vec[i].size()>0)
			fun(i,0);
	}
	for(i=0;i<n;i++){
		for(int j=0;j<vec[i].size();j++)
			cout<<vec[i][j]<<" ";
		cout<<a[i]<<" ";
	}
	for(int j=0;j<vec[n].size();j++)
			cout<<vec[n][j]<<" ";
}

Compilation message

zalmoxis.cpp: In function 'void fun(int, int)':
zalmoxis.cpp:9:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(vec[i].size()<=j)
     ~~~~~~~~~~~~~^~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:67:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<vec[i].size();j++)
               ~^~~~~~~~~~~~~~
zalmoxis.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=0;j<vec[n].size();j++)
              ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 5876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 26 ms 6076 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 30 ms 6108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 33 ms 6108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 41 ms 6208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 40 ms 6212 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 6212 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 37 ms 6212 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 31 ms 6344 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 34 ms 6420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 52 ms 6420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 37 ms 6420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 29 ms 6420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 27 ms 6420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 28 ms 6436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 32 ms 6436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 50 ms 6436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Correct 125 ms 11940 KB Output is correct
13 Correct 150 ms 11940 KB Output is correct
14 Correct 135 ms 12088 KB Output is correct