Submission #726411

# Submission time Handle Problem Language Result Execution time Memory
726411 2023-04-18T21:34:03 Z professionalACer A Huge Tower (CEOI10_tower) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 9;
int main() {
  int N, D;
  cin >> N >> D;
  int A[N];
  for (auto &x : A) cin >> x;
  sort(a.begin(), a.end());
  int p = 0, ans = 1;
  for (int i = 0; i < N; i++) {
    while (p < N - 1 && a[p + 1] - a[i] <= d) p++;
    int d = p - i + 1;
    ans = (ans = ans * d) % mod;
  }
  cout << ans << endl;
}

Compilation message

cc1plus: error: '::main' must return 'int'
tower.cpp: In function 'int main()':
tower.cpp:10:8: error: 'a' was not declared in this scope
   10 |   sort(a.begin(), a.end());
      |        ^
tower.cpp:13:44: error: 'd' was not declared in this scope
   13 |     while (p < N - 1 && a[p + 1] - a[i] <= d) p++;
      |                                            ^
tower.cpp:15:9: warning: operation on 'ans' may be undefined [-Wsequence-point]
   15 |     ans = (ans = ans * d) % mod;
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:15:9: warning: operation on 'ans' may be undefined [-Wsequence-point]