Submission #382936

# Submission time Handle Problem Language Result Execution time Memory
382936 2021-03-28T14:43:08 Z Iwanttobreakfree Baloni (COCI15_baloni) C++17
100 / 100
544 ms 492 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n,h,num;
	cin>>n;
	vector<int> v;
	cin>>h;
	v.push_back(h);
	for(int i=1;i<n;i++){
		cin>>num;
		bool pos=false;
		if(num<h){
		for(int j=0;j<v.size();j++){
			if(v[j]==num+1){
			v[j]=num;
			pos=true;
			break;	
			}
		}
	}
		if(!pos){
		v.push_back(num);
		if(num>h)h=num;	
		}
	}
	cout<<v.size();
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:18:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(int j=0;j<v.size();j++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 302 ms 492 KB Output is correct
6 Correct 544 ms 428 KB Output is correct
7 Correct 447 ms 364 KB Output is correct
8 Correct 430 ms 492 KB Output is correct
9 Correct 393 ms 408 KB Output is correct
10 Correct 474 ms 492 KB Output is correct