답안 #878185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878185 2023-11-24T06:55:24 Z heeheeheehaaw Money (IZhO17_money) C++17
0 / 100
1 ms 4444 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int n, aib[1000005];
int v[1000005];
 
void update(int poz, int val)
{
    for(int i = poz; i <= 1000000; i += (i & (-i)))
        aib[i] += val;
    return;
}
 
int query(int poz)
{
    int sum = 0;
    for(int i = poz; i >= 1; i -= (i & (-i)))
        sum += aib[i];
    return sum;
}
 
int main()
{
    map<int, int> m1, m2;
    cin>>n;
    for(int i =1 ; i <= n; i++)
        cin>>v[i], m1[v[i]] = 1;
    /*int cnt = 0;
    for(auto it : m1)
        m2[it.first] = ++cnt;
    for(int i = 1; i <= n; i++)
        [i] = m*/
    
    int rez = 1, prev = 0;
    for(int i = 1; i <= n; i++)
    {
        if(v[i] < v[i - 1] || query(v[i]-1) - query(v[i - 1]) > 0)
        {
            rez++;
        }
        prev = v[i];
        update(v[i], 1);
    }
    
    cout<<rez;
 
    return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:35:18: warning: variable 'prev' set but not used [-Wunused-but-set-variable]
   35 |     int rez = 1, prev = 0;
      |                  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -