답안 #92834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92834 2019-01-05T09:14:35 Z SamAnd Money (IZhO17_money) C++17
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;

int n;
int a[N];

int t[N];

void ubd(int x)
{
    while (x < N)
    {
        t[x]++;
        x += (x & (-x));
    }
}

int qry(int l, int r)
{
    if (l > r)
        return 0;
    int ans = 0;
    while (r > 0)
    {
        ans += t[r];
        r -= (r & (-r));
    }
    --l;
    while (l > 0)
    {
        ans -= t[l];
        l -= (l & (-l));
    }
    return ans;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    int ans = 1;
    ubd(a[1]);
    for (int i = 2; i <= n; ++i)
    {
        if (a[i] >= a[i - 1] && qry(a[i - 1] + 1, a[i] - 1) == 0)
            continue;
        else
            ++ans;
    }
    cout << ans << endl;
    return 0;
}

Compilation message

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