Submission #81635

# Submission time Handle Problem Language Result Execution time Memory
81635 2018-10-25T16:21:59 Z xiaowuc1 Baloni (COCI15_baloni) C++14
100 / 100
434 ms 5768 KB
#include <bits/stdc++.h>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);

ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, ll> pill;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<vector<ll>> matrix;

int main() {
  int n;
  scanf("%d", &n);
  int ret = 0;
  map<int, int> dp;
  while(n--) {
    int t;
    scanf("%d", &t);
    if(dp.count(t)) {
      if(--dp[t] == 0) dp.erase(t);
      if(t-1) dp[t-1]++;
    }
    else {
      ret++;
      if(t-1) dp[t-1]++;
    }
  }
  printf("%d\n", ret);
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
baloni.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 5 ms 644 KB Output is correct
5 Correct 434 ms 4180 KB Output is correct
6 Correct 349 ms 5680 KB Output is correct
7 Correct 262 ms 5680 KB Output is correct
8 Correct 267 ms 5768 KB Output is correct
9 Correct 341 ms 5768 KB Output is correct
10 Correct 316 ms 5768 KB Output is correct