답안 #709029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709029 2023-03-13T04:35:27 Z vjudge1 Baloni (COCI15_baloni) C++17
40 / 100
2000 ms 4696 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define sc second
#define pb(x) push_back(x)
#define ll long long
#define sp ' '
#define pairs pair<int, int>
#define mp make_pair
void show(vector <int> v){
	for(int i=0; i<v.size(); i++){
		cout<<v[i]<<sp;
	}
	cout<<endl;
}
int main(){
	int n,cnt=0;
	cin>>n;
	vector <int> v;
	for(int i=0; i<n; i++){
		int h;
		cin>>h;
		v.pb(h);
	}
	while(v.size()>0){
		int h1=v[0]-1;
		for(int j=1; j<v.size(); j++){
			if(v[j]==h1){
				v.erase(v.begin()+j);
				j--;
				h1--;
			}
		}
		v.erase(v.begin());
		cnt++;
	}
	cout<<cnt;
	return 0;
}

Compilation message

baloni.cpp: In function 'void show(std::vector<int>)':
baloni.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<v.size(); i++){
      |               ~^~~~~~~~~
baloni.cpp: In function 'int main()':
baloni.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int j=1; j<v.size(); j++){
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
5 Execution timed out 2093 ms 4492 KB Time limit exceeded
6 Execution timed out 2076 ms 4484 KB Time limit exceeded
7 Execution timed out 2063 ms 4696 KB Time limit exceeded
8 Execution timed out 2079 ms 4492 KB Time limit exceeded
9 Execution timed out 2088 ms 4464 KB Time limit exceeded
10 Execution timed out 2075 ms 4436 KB Time limit exceeded