답안 #88793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88793 2018-12-08T18:48:29 Z asifthegreat Baloni (COCI15_baloni) C++14
0 / 100
255 ms 27124 KB
#include <bits/stdc++.h>
using namespace std;

const int  N = 1000003;

int ara[N],tree[N],n;

vector<int>v;

void update(int indx)
{
    while(indx <= n){
        tree[indx]++;
        indx += indx&-indx;
    }
}
int get(int indx)
{
    int sum = 0;
    while(indx > 0){
        sum += tree[indx];
        indx -= indx & -indx;
    }
    return sum;
}

int main()
{
    scanf("%d",&n);
    for(int i = 1; i <= n;i++)scanf("%d",&ara[i]);
    for(int i = n; i >= 1;i--){
        update(ara[i]);
        v.push_back(get(ara[i]));
    }
    sort(v.begin(),v.end(),greater<int>());
    int cnt = 0,sum = 0;
    for(auto i: v){
        sum += i;
        cnt++;
        //cout << i << " ";
        if(sum > n)break;
    }
    cout << cnt << endl;

    return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
baloni.cpp:30:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n;i++)scanf("%d",&ara[i]);
                               ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Incorrect 3 ms 608 KB Output isn't correct
4 Incorrect 3 ms 608 KB Output isn't correct
5 Incorrect 233 ms 11620 KB Output isn't correct
6 Incorrect 255 ms 15460 KB Output isn't correct
7 Incorrect 216 ms 17760 KB Output isn't correct
8 Incorrect 202 ms 20428 KB Output isn't correct
9 Incorrect 224 ms 23880 KB Output isn't correct
10 Incorrect 247 ms 27124 KB Output isn't correct