답안 #163865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163865 2019-11-15T18:58:08 Z beso123 Baloni (COCI15_baloni) C++14
100 / 100
338 ms 10888 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[1000001],used[1000001];
main(){
scanf("%i64d",&n);
for(int k=1;k<=n;k++)
    scanf("%I64d",&a[k]);
int ans=0;
ans++;
used[a[1]]++;
for(int k=2;k<=n;k++){
   if(used[a[k]+1]==0)
        ans++;
   else used[a[k]+1]--;
   used[a[k]]++;
}
cout<<ans;
return 0;
}

Compilation message

baloni.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
baloni.cpp: In function 'int main()':
baloni.cpp:6:17: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 scanf("%i64d",&n);
               ~~^
baloni.cpp:8:24: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
     scanf("%I64d",&a[k]);
                   ~~~~~^
baloni.cpp:6:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%i64d",&n);
 ~~~~~^~~~~~~~~~~~
baloni.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%I64d",&a[k]);
     ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 321 ms 10204 KB Output is correct
6 Correct 338 ms 10888 KB Output is correct
7 Correct 276 ms 9004 KB Output is correct
8 Correct 274 ms 8824 KB Output is correct
9 Correct 295 ms 9636 KB Output is correct
10 Correct 329 ms 9844 KB Output is correct