Submission #648978

#TimeUsernameProblemLanguageResultExecution timeMemory
648978tvladm2009Vudu (COCI15_vudu)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int ll using ll = long long; int const nmax = 1000000; int v[5 + nmax], sp[5 + nmax]; int index[5 + nmax], aib[5 + nmax]; std::pair<int, int> aux[1 + nmax]; void normalize(int n) { for(int i = 1;i <= n; i++) aux[i] = {sp[i], i}; std::sort(aux + 1, aux + n + 1); int cnt = 1; index[aux[1].second] = 1; for(int i = 1;i <= n; i++) { if(aux[i].first != aux[i - 1].first) cnt++; index[aux[i].second] = cnt; } } void update(int x) { for(int i = x;i <= nmax; i += i & -i) aib[i]++; } int query(int x) { int ans = 0; for(int i = x;1 <= i; i -= i & -i) ans += aib[i]; return ans; } signed main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); long long n, p; std::cin >> n; for(int i = 1;i <= n; i++) std::cin >> v[i]; std::cin >> p; for(int i = 1;i <= n; i++) { v[i] -= p; sp[i] = sp[i - 1] + v[i]; } normalize(n); ll ans = 0; for(int i = 1;i <= n; i++) { ans += query(index[i]); update(index[i]); } for(int i = 1;i <= n; i++) { if(sp[i] >= 0) ans++; } std::cout << ans; return 0; }

Compilation message (stderr)

vudu.cpp:9:19: error: 'll index [1000005]' redeclared as different kind of entity
    9 | int index[5 + nmax], aib[5 + nmax];
      |                   ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from vudu.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
vudu.cpp: In function 'void normalize(ll)':
vudu.cpp:17:8: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   17 |   index[aux[1].second] = 1;
      |        ^
vudu.cpp:21:10: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   21 |     index[aux[i].second] = cnt;
      |          ^
vudu.cpp: In function 'int main()':
vudu.cpp:54:23: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   54 |     ans += query(index[i]);
      |                       ^
vudu.cpp:55:17: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   55 |     update(index[i]);
      |                 ^