답안 #546539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546539 2022-04-07T18:48:22 Z MilosMilutinovic A Huge Tower (CEOI10_tower) C++14
컴파일 오류
0 ms 0 KB
#include <stdio.h>

#define N	100000
#define MD	1000000007

int n, d, aa[N], bb[N];
long long dp[N];

void sort(int l, int r) {
	int i, cc0, cc1;
  
	if (l >= r)
		return;
	int m = (l + r) / 2;
	sort(l, m);
	sort(m + 1, r);
	cc0 = l, cc1 = m + 1;
	for (i = l; i <= r; i++)
		if (cc0 > m || (cc1 <= r && aa[cc0] > aa[cc1]))
			bb[i] = aa[cc1++];
		else
			bb[i] = aa[cc0++];
	for (i = l; i <= r; i++)
		aa[i] = bb[i];
}

int main() {
	int i, j;
  
	scanf("%d%d", &n, &d);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	sort(0, n - 1);
	for (i = 0, j = 0; i < n; i++) {
		while (a[j] < a[i] - d)
			j++;
		dp[i] = (i == 0 ? 1LL : dp[i - 1]) * (i - j + 1), dp[i] = (dp[i] % MD);
    }
	printf("%lld\n", dp[n - 1]);
	return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:35:10: error: 'a' was not declared in this scope
   35 |   while (a[j] < a[i] - d)
      |          ^
tower.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d%d", &n, &d);
      |  ~~~~~^~~~~~~~~~~~~~~~
tower.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d", &aa[i]);
      |   ~~~~~^~~~~~~~~~~~~~