답안 #915335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915335 2024-01-23T17:43:02 Z jpfr12 Baloni (COCI15_baloni) C++14
100 / 100
45 ms 7760 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<int> dp(1e6+1);
  int sum = 0;
  for(int& i: vec){
    if(dp[i+1] > 0){
      dp[i+1]--;
      dp[i]++;
    }
    else{
      dp[i]++;
      sum++;
    }
  }
  cout << sum << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 2 ms 4188 KB Output is correct
5 Correct 44 ms 7396 KB Output is correct
6 Correct 45 ms 7760 KB Output is correct
7 Correct 36 ms 6996 KB Output is correct
8 Correct 35 ms 7384 KB Output is correct
9 Correct 39 ms 7248 KB Output is correct
10 Correct 44 ms 7508 KB Output is correct