Skip to content

Commit d2d61b0

Browse files
committed
Brush 2
1 parent 47ff16e commit d2d61b0

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

Diff for: 1016-Brush-2.cpp

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <vector>
2+
#include <set>
3+
#include <stdio.h>
4+
#include <iostream>
5+
using namespace std;
6+
7+
int main()
8+
{
9+
10+
int t;
11+
int n;
12+
int x;
13+
int y;
14+
int w;
15+
int temp;
16+
int count;
17+
18+
scanf("%d", &t);
19+
20+
for (int j = 1; j <= t; j++) {
21+
scanf("%d", &n);
22+
scanf("%d", &w);
23+
vector <int> a;
24+
25+
26+
for (int i = 0; i < n; i++) {
27+
scanf("%d %d", &x, &y);
28+
a.push_back(y);
29+
}
30+
31+
set <int> s(a.begin(), a.end());
32+
a.assign(s.begin(), s.end());
33+
34+
temp = a[0];
35+
count = 1;
36+
37+
for (int i = 0; i < a.size(); i++) {
38+
if(temp + w < a[i]) {
39+
40+
temp = a[i];
41+
42+
count++;
43+
}
44+
45+
}
46+
47+
printf("Case %d: %d\n", j, count);
48+
49+
50+
}
51+
52+
53+
}
54+

Diff for: README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ This is a normal Memoization with Bit masking type problem. Normal recursion wit
3838
This is one is a really simple graph problem. Keep marking the visited nodes to avoid visiting them again
3939

4040
###1014 - Ifter Party
41-
This is also a normal Ad-Hoc problem. The simplified task is to find the divisors of p - l which are greater than l
41+
This is also a normal Ad-Hoc problem. The simplified task is to find the divisors of p - l which are greater than l.
42+
43+
###1016 - Brush II
44+
This is yet another adhoc problem. What you need to do is to ietrate over all the y points in ascending order in such a way that you increase the counter only when the difference of ym, ym+1, ....yn becomes greater than w. The counter would give you the answer.

0 commit comments

Comments
 (0)