제출 #362853

#제출 시각아이디문제언어결과실행 시간메모리
362853shahriarkhanMoney (IZhO17_money)C++14
100 / 100
210 ms15084 KiB
#include<bits/stdc++.h>
using namespace std ;

const int mx = 1e6 + 45 ;

int T[mx] ;

void add(int pos)
{
    for(; pos < mx ; pos += (pos & -pos)) ++T[pos] ;
}

int get(int pos)
{
    int res = 0 ;
    for(; pos > 0 ; pos -= (pos & -pos)) res += T[pos] ;
    return res ;
}

int find_max(int l , int r)
{
    if(l>r) return 0 ;
    return get(r) - get(l-1) ;
}

int main()
{
    int n ;
    scanf("%d",&n) ;
    int a[n+1] , ans = 0 ;
    for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ;
    for(int i = 1 ; i <= n ; ++i)
    {
        int ed = i ;
        while(((ed+1)<=n) && ((a[ed+1]>=a[ed]) && (!find_max(a[i]+1,a[ed+1]-1)))) ++ed ;
        ++ans ;
        for(int j = i ; j <= ed ; ++j) add(a[j]) ;
        i = ed ;
    }
    printf("%d\n",ans) ;
    return 0 ;
}

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'int main()':
money.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
money.cpp:31:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...