Skip to content

Commit

Permalink
Fence Painting
Browse files Browse the repository at this point in the history
  • Loading branch information
tynnp authored Dec 25, 2024
1 parent d8cbfe6 commit 177f1df
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions USACO/567.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
#include <iostream>
#include <algorithm>
using namespace std;

#define endl '\n'
#define int long long
#define inp freopen("paint.in", "r", stdin)
#define out freopen("paint.out", "w", stdout)
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0)
int main() {
freopen("paint.in", "r", stdin);
freopen("paint.out", "w", stdout);

const int MAXN = 1e6 + 5;
const int MOD = 1e9 + 7;

int a, b, c, d, ans;
bool check[MAXN];

signed main() {
fastIO; inp; out;
bool paint[105];
int a, b, c, d;
cin >> a >> b >> c >> d;

for (int i = 0; i < 105; i++)
paint[i] = false;

for (int i = a; i < b; i++)
check[i] = true;
paint[i] = true;

for (int i = c; i < d; i++)
check[i] = true;
paint[i] = true;

int ans = 0;
for (int i = 0; i < 105; i++)
ans += paint[i];

for (int i = 0; i < MAXN; i++)
ans += check[i];

cout << ans;
return 0;
}

0 comments on commit 177f1df

Please sign in to comment.