답안 #38217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38217 2018-01-03T04:29:36 Z Talant Money (IZhO17_money) C++14
0 / 100
0 ms 13732 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const ll inf = (ll)1e9 + 7;
const int N = (int)1e6 + 1;

int n;
int b[N + 5],a[N + 5],t[N + 5],lst = 1,id = 1;
int ans;

void update (int pos) {
        for (; pos <= N; pos += (pos & (-pos)))
                t[pos] ++;
}

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

int main () {
        scanf ("%d", &n);

        for (int i = 1; i <= n; i ++)
                scanf ("%d", &b[i]);

        for (int i = 1; i <= n; i ++) {
                if (b[i - 1] != b[i])
                        a[id] = b[i],id ++;
        }
        n = id - 1;
        update (a[1]);

        for (int i = 2; i <= n; i ++) {
                update (a[i]);

                if (a[i] > a[i - 1]) {
                        int o = get(a[i] - 1) - get(a[i - 1]);
                        if (o) ans ++;

                }
                else ans ++;
        }
        ans ++;

        cout << ans << endl;
}
/**
6
3 6 4 5 1 2
**/

Compilation message

money.cpp: In function 'int main()':
money.cpp:33:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", &n);
                         ^
money.cpp:36:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf ("%d", &b[i]);
                                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13732 KB Output is correct
2 Correct 0 ms 13732 KB Output is correct
3 Correct 0 ms 13732 KB Output is correct
4 Correct 0 ms 13732 KB Output is correct
5 Correct 0 ms 13732 KB Output is correct
6 Correct 0 ms 13732 KB Output is correct
7 Correct 0 ms 13732 KB Output is correct
8 Correct 0 ms 13732 KB Output is correct
9 Correct 0 ms 13732 KB Output is correct
10 Correct 0 ms 13732 KB Output is correct
11 Correct 0 ms 13732 KB Output is correct
12 Incorrect 0 ms 13732 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13732 KB Output is correct
2 Correct 0 ms 13732 KB Output is correct
3 Correct 0 ms 13732 KB Output is correct
4 Correct 0 ms 13732 KB Output is correct
5 Correct 0 ms 13732 KB Output is correct
6 Correct 0 ms 13732 KB Output is correct
7 Correct 0 ms 13732 KB Output is correct
8 Correct 0 ms 13732 KB Output is correct
9 Correct 0 ms 13732 KB Output is correct
10 Correct 0 ms 13732 KB Output is correct
11 Correct 0 ms 13732 KB Output is correct
12 Incorrect 0 ms 13732 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13732 KB Output is correct
2 Correct 0 ms 13732 KB Output is correct
3 Correct 0 ms 13732 KB Output is correct
4 Correct 0 ms 13732 KB Output is correct
5 Correct 0 ms 13732 KB Output is correct
6 Correct 0 ms 13732 KB Output is correct
7 Correct 0 ms 13732 KB Output is correct
8 Correct 0 ms 13732 KB Output is correct
9 Correct 0 ms 13732 KB Output is correct
10 Correct 0 ms 13732 KB Output is correct
11 Correct 0 ms 13732 KB Output is correct
12 Incorrect 0 ms 13732 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 13732 KB Output is correct
2 Correct 0 ms 13732 KB Output is correct
3 Correct 0 ms 13732 KB Output is correct
4 Correct 0 ms 13732 KB Output is correct
5 Correct 0 ms 13732 KB Output is correct
6 Correct 0 ms 13732 KB Output is correct
7 Correct 0 ms 13732 KB Output is correct
8 Correct 0 ms 13732 KB Output is correct
9 Correct 0 ms 13732 KB Output is correct
10 Correct 0 ms 13732 KB Output is correct
11 Correct 0 ms 13732 KB Output is correct
12 Incorrect 0 ms 13732 KB Output isn't correct
13 Halted 0 ms 0 KB -