Submission #1228990

#TimeUsernameProblemLanguageResultExecution timeMemory
1228990adadArt Exhibition (JOI18_art)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define TASK ""
#define MASK(i) (1<<(i))
#define BIT(x, i) (((x)>>(i))&1)
#define int long long
#define fi   first
#define se   second
using namespace std;
const long long INF = 1e17, MOD = 1e9 + 7, maxN = 5e5 + 5;

int n, p[maxN];
pair<int, int> x[maxN];

signed main() {
    if (fopen(TASK ".INP", "r")) {
        freopen(TASK ".INP", "r", stdin);
        freopen(TASK ".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> x[i].fi >> x[i].se;
    p[1] = 1;
	for(int i = 2; i <= n; i ++) p[i] = p[i - 1] + x[i].se;
	int maa = 0, res = 0;
	// p[r] - p[l - 1] - a[r].fi + a[l].fi
	// (p[r] - a[r].fi) + (a[l].fi - p[l - 1])
	for(int i = 1; i <= n; i ++) {
		ma = max(ma, a[i].fi - p[i - 1]);
		res = max(res, ma + p[i] - a[i].fi);
	}
	cout << res;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:29:17: error: 'ma' was not declared in this scope; did you mean 'maa'?
   29 |                 ma = max(ma, a[i].fi - p[i - 1]);
      |                 ^~
      |                 maa
art.cpp:29:30: error: 'a' was not declared in this scope
   29 |                 ma = max(ma, a[i].fi - p[i - 1]);
      |                              ^
art.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(TASK ".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(TASK ".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~