Submission #1218413

#TimeUsernameProblemLanguageResultExecution timeMemory
1218413bangan송신탑 (IOI22_towers)C++20
Compilation error
0 ms0 KiB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

#define chmax(a, b) a = max(a, b)

#define pb push_back

const int maxn = 1e5 + 4;

int n;
int h[maxn];
int dp[maxn];
int pre[maxn];

int local_min(int i) {
	if (1 <= i-1 && h[i] > h[i-1]) return 0;
	if (i+1 <= n && h[i] > h[i+1]) return 0;
	return 1;
}

void init(int N, std::vector<int> H) {
	n = N;
	for (int i=1; i<=n; i++) h[i] = H[i];
	for (int i=1; i<=n; i++) pre[i] = pre[i-1] + local_min(i);
}

int max_towers(int L, int R, int D) {
	if (L==R) return 1;
	L++; R++;
	int ans = pre[R] - pre[L-1];
	ans -= local_min(L);
	ans -= local_min(R);
	ans += (h[L] < h[L+1]);
	ans += (h[R] < h[R-1]);
	chmax(ans+1, 1);
	return ans;
}

Compilation message (stderr)

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:36:18: error: lvalue required as left operand of assignment
   36 |         chmax(ans+1, 1);
      |               ~~~^~
towers.cpp:5:21: note: in definition of macro 'chmax'
    5 | #define chmax(a, b) a = max(a, b)
      |                     ^