답안 #361249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361249 2021-01-28T23:52:04 Z MilosMilutinovic Money (IZhO17_money) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1000050;
int n,a[N],bit[N];
int Get(int x){int res=0;for(;x>0;x-=x&(-x))res+=bit[x];return res;}
void Add(int x){for(;x<N;x+=x&(-x))bit[x]++;}
int main(){
    scanf("%i",&n);
    for(int i=1;i<=n;i++)scanf("%i",&a[i]);
    int j=1,ans=1;
    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]||Get(a[i])>Get(a[j]-1)){
            ans++;
            while(j<i)Add(a[j]),j++;
        }
    }
    printf("%i",ans);
    return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%i",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:9:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     for(int i=1;i<=n;i++)scanf("%i",&a[i]);
      |                          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -