Submission #88793

#TimeUsernameProblemLanguageResultExecution timeMemory
88793asifthegreatBaloni (COCI15_baloni)C++14
0 / 100
255 ms27124 KiB
#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 (stderr)

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]);
                               ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...