답안 #258724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258724 2020-08-06T12:36:15 Z leductoan Baloni (COCI15_baloni) C++
100 / 100
82 ms 3960 KB
#include<bits/stdc++.h>
using namespace std;
#define task "NAME"
#define lwb lower_bound
#define upb upper_bound
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> p3i;
typedef pair<pii,pii> p4i;

int cnt[1000005],n,ans;
void solve()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int x; cin>>x;
        if(cnt[x+1]>0)
        {
            ++cnt[x];
            --cnt[x+1];
        }
        else
        {
            ++cnt[x];
            ++ans;
        }
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solve();
}





Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(task".inp","r",stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
baloni.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(task".out","w",stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 65 ms 3960 KB Output is correct
6 Correct 82 ms 3832 KB Output is correct
7 Correct 54 ms 3192 KB Output is correct
8 Correct 50 ms 3192 KB Output is correct
9 Correct 64 ms 3576 KB Output is correct
10 Correct 63 ms 3472 KB Output is correct