Submission #915332

# Submission time Handle Problem Language Result Execution time Memory
915332 2024-01-23T17:35:06 Z jpfr12 Baloni (COCI15_baloni) C++14
40 / 100
2000 ms 10832 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
using namespace std;
int MOD = (int)1e9;
int MAXN = 1e6;
 
//classes

 
 
//global


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("input.txt");
  //ofstream fout("output.txt");
  //stop
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int& i: vec) cin >> i;
  vector<bool> valid(n, true);
  vector<int> parent(n, -1);
  for(int i = 1; i < n; i++){
    int index = -1;
    for(int j = 0; j < i; j++){
      if(vec[i] == vec[j]-1 && valid[j]){
        index = j;
      }
    }
    //cout << "i: " << i << " index: " << index << '\n';
    if(index > -1){
      valid[index] =false;
      parent[i] = index;
    }
  }
  int sum = 0;
  for(bool i: valid) if(i) sum++;
  cout << sum << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 9 ms 600 KB Output is correct
5 Execution timed out 2068 ms 10324 KB Time limit exceeded
6 Execution timed out 2035 ms 10832 KB Time limit exceeded
7 Execution timed out 2035 ms 9044 KB Time limit exceeded
8 Execution timed out 2048 ms 8788 KB Time limit exceeded
9 Execution timed out 2044 ms 9556 KB Time limit exceeded
10 Execution timed out 2021 ms 9812 KB Time limit exceeded