Submission #383291

# Submission time Handle Problem Language Result Execution time Memory
383291 2021-03-29T13:07:44 Z victoriad Baloni (COCI15_baloni) C++14
100 / 100
539 ms 6636 KB
#include <fstream>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<bool>p(n,false);
    vector<int>b;
    int x=0;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int y;
    b.push_back(a[0]-1);
    for(int i=1;i<n;i++){
        if(p[i])continue;
        for(int j=0;j<b.size();j++){
            if(a[i]==b[j]){
                b[j]--;
                p[i]=true;
                break;
            }
        }
        if(!p[i])
        b.push_back(a[i]-1);
    }
    cout<<b.size();
  return 0;
}
 
 
 
 

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int j=0;j<b.size();j++){
      |                     ~^~~~~~~~~
baloni.cpp:17:9: warning: unused variable 'x' [-Wunused-variable]
   17 |     int x=0;
      |         ^
baloni.cpp:22:9: warning: unused variable 'y' [-Wunused-variable]
   22 |     int y;
      |         ^
# 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 294 ms 6252 KB Output is correct
6 Correct 539 ms 6636 KB Output is correct
7 Correct 442 ms 5996 KB Output is correct
8 Correct 416 ms 6072 KB Output is correct
9 Correct 377 ms 6124 KB Output is correct
10 Correct 448 ms 6252 KB Output is correct