# CodeForces - 434D Nanami's Power Plant

### Description

$n\le 50,m\le 100,-100\le l_i,r_i\le 100)$

### Solution

#include<bits/stdc++.h>
using namespace std;

template <class T> void read(T &x) {
x = 0; bool flag = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) flag |= ch == '-';
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48; flag ? x = ~x + 1 : 0;
}

#define N 10010
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define INF 0x3f3f3f3f

int head[N], cur[N], tot = 1, q[N], dep[N];
struct edge { int v, c, next; }e[200010];
inline void insert(int u, int v, int c) {
e[++tot].v = v, e[tot].c = c, e[tot].next = head[u]; head[u] = tot;
}
inline void add(int u, int v, int c) { insert(u, v, c), insert(v, u, 0); }
inline bool bfs(int S, int T) {
memset(dep, 0, sizeof dep); dep[S] = 1;
int l = 1, r = 1; q[1] = S;
while (l <= r) {
int u = q[l++];
for (int i = head[u], v; i; i = e[i].next) if (e[i].c && !dep[v = e[i].v]) {
dep[v] = dep[u] + 1, q[++r] = v;
if (v == T) return 1;
}
}
return 0;
}
int dfs(int u, int dist, int T) {
if (u == T) return dist;
int ret = 0;
for (int &i = head[u], v; i; i = e[i].next) if (dep[v = e[i].v] == dep[u] + 1 && e[i].c) {
int d = dfs(v, min(dist - ret, e[i].c), T);
e[i].c -= d, e[i ^ 1].c += d, ret += d;
if (ret == dist) return dist;
}
if (!ret) dep[u] = -1;
return ret;
}

int dinic(int S, int T) {
while (bfs(S, T)) ret += dfs(S, INF, T), memcpy(head, cur, sizeof cur);
return ret;
}

int a[N], b[N], c[N], l[N], r[N], node[N];

inline int f(int x, int y) { return a[x] * y * y + b[x] * y + c[x]; }

inline int id(int x, int y) { return node[x] + y - l[x]; }

int main() {
int cnt = 0, M = 0;
rep(i, 1, n) {
node[i] = cnt + 1, cnt += r[i] - l[i] + 2;
rep(j, l[i], r[i]) M = max(M, f(i, j));
}
int S = cnt + 1, T = S + 1;
rep(i, 1, n) {
}