Submission #232940

# Submission time Handle Problem Language Result Execution time Memory
232940 2020-05-18T17:39:21 Z kristopher23 Mountains (NOI20_mountains) C++17
64 / 100
2000 ms 4608 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using vi = vector<int>;
using vll = vector<ll>;

using pi = pair<int, int>;
using pll = pair<ll, ll>;

constexpr auto MOD = 1e9 + 7;
constexpr auto INF = 0x3f3f3f3f;

#define rep(i, a, b) for (auto i = a; i < b; ++i)

template <class T> inline T square(T x) { return x * x; };

template <class T> void print(const T &val) { cout << val << '\n'; }

template <class Iterator> void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; ++it) {
    cout << *it << ' ';
  }

  cout << '\n';
}

using ull = unsigned long long;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  ll n;
  cin >> n;

  vector<ull> a(n);

  for (auto &i : a) {
    cin >> i;
  }

  ull ans = 0;

  for (ull i = 1; i < n - 1; ++i) {
    ull x = 0, y = 0;
    for (ull j = 0; j < i; ++j) {
      if (a[j] < a[i]) {
        ++x;
      }
    }
    for (ull j = i + 1; j < n; ++j) {
      if (a[j] < a[i]) {
        ++y;
      }
    }

    ans += (x * y);
  }

  print(ans);
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ull i = 1; i < n - 1; ++i) {
                   ~~^~~~~~~
Mountains.cpp:54:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ull j = i + 1; j < n; ++j) {
                         ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 2081 ms 4608 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2087 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2087 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 59 ms 640 KB Output is correct
12 Correct 57 ms 640 KB Output is correct
13 Correct 58 ms 640 KB Output is correct
14 Correct 57 ms 640 KB Output is correct
15 Correct 57 ms 640 KB Output is correct
16 Correct 56 ms 652 KB Output is correct
17 Correct 60 ms 652 KB Output is correct
18 Correct 57 ms 640 KB Output is correct
19 Correct 57 ms 512 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2087 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 2081 ms 4608 KB Time limit exceeded
3 Halted 0 ms 0 KB -