Search is not available for this dataset
name
stringlengths 2
112
| description
stringlengths 29
13k
| source
int64 1
7
| difficulty
int64 0
25
| solution
stringlengths 7
983k
| language
stringclasses 4
values |
---|---|---|---|---|---|
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i, limit;
int[] distance = new int[5];
for(i = 0; i < 5; i++) distance[i] = Integer.parseInt(sc.next());
limit = Integer.parseInt(sc.next());
if(distance[4] - distance[0] > limit) System.out.println(":(");
else System.out.println("Yay!");
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,_,_,_,e,k=[int(input()) for _ in range(6)]
print(["Yay!",":("][e-a>k]) | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main()
{
int A, B, C, D, E, K;
cin >> A >> B >> C >> D >> E >> K;
cout << (E - A > K ? ":(" : "Yay!") << endl;
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int max = 0;
int min = 123;
for(int i = 0; i < 5; i++ ){
int a = sc.nextInt();
if(a > max){ max = a; }
if(a < min){ min = a; }
}
int k = sc.nextInt();
if(max - min > k) {
System.out.println(":(");
} else {
System.out.println("Yay!");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] A = new int[5];
for(int i = 0; i < 5; i++)
A[i] = sc.nextInt();
Arrays.sort(A);
if(A[4]-A[0] <= sc.nextInt())
System.out.println("Yay!");
else
System.out.println(":(");
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a = [int(input()) for i in range(6)]
print("Yay!") if abs(a[4] - a[0]) <= a[5] else print(":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
int main()
{
int a,b,c,d,e,k;
std::cin >> a >> b >> c >> d >> e >> k;
std::cout << (e - a <= k ? "Yay!" : ":(" ) << std::endl;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
int a,b,c,d,e,k;
cin >>a>>b>>c>>d>>e>>k;
cout <<(e-a<=k?"Yay!":":(")<<endl;
return 0;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a=[int(input()) for i in range(6)]
b=a[4]-a[0]
if a[5]>=b:
print('Yay!')
else:
print(':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a[] = new int[5];
for(int i = 0; i < 5; ++i)
a[i] = sc.nextInt();
int k = sc.nextInt();
sc.close();
String ans[] = {":(", "Yay!"};
int an = 1;
if(a[4] - a[0] > k)an = 0;
System.out.println(ans[an]);
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main(void){
// Your code here!
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a>k)cout<<":("<<endl;
else cout<<"Yay!"<<endl;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int d=scan.nextInt();
int e=scan.nextInt();
int f=scan.nextInt();
if((e-a)<=f) {
System.out.println("Yay!");
}
else {
System.out.println(":(");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, k;
cin>>a>>b>>c>>d>>e>>k;
if (e-a>k) cout << ":(\n";
else cout << "Yay!\n";
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | n = 6;
a = [input() for i in range(n)];
k = a[-1];
ans = "Yay!";
for i in range(n-1):
for j in reversed(range(n-1)):
if k < a[i] - a[j]:
ans = ":( ";
break;
print ans; | PYTHON |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
int k;
cin >> x >> y >> y >> y >> y;
cin >> k;
cout << (y-x > k? ":(":"Yay!") << endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | antenas = [int(raw_input()) for i in range(5)]
dist = int(raw_input())
antenas.sort()
antenas2 = antenas
dists = [antenas2[j]-antenas[i] for i in range(5) for j in range(5)]
n = sum(i > dist for i in dists)
if n == 0:
print "Yay!"
else:
print ":(" | PYTHON |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,_,_,_,e,k=[int(input()) for i in range(6)]
print(":(" if e-a>k else "Yay!") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int[] arr = new int[5];
for (int i = 0; i < 5; i++) {
arr[i] = reader.nextInt();
}
int k = reader.nextInt();
Arrays.sort(arr);
String ans = ":(";
if (arr[4]-arr[0] <= k) {
ans = "Yay!";
}
System.out.print(ans);
reader.close();
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | l = [int(input()) for i in range(6) ]
print(":(" if l[4] - l[0] > l[5] else "Yay!") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a=[int(input()) for _ in range(6)]
print('Yay!' if a[4]-a[0]<=a[5] else ':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[5];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
int k = sc.nextInt();
if (a[4] - a[0] > k) {
System.out.println(":(");
} else {
System.out.println("Yay!");
}
sc.close();
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int[] a = new int[5];
for (int i = 0; i < 5; i++) {
a[i] = sc.nextInt();
}
int k = sc.nextInt();
if (a[4] - a[0] <= k) {
sb.append("Yay!");
} else {
sb.append(":(");
}
System.out.println(sb);
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<iostream>
using namespace std;
int main() {
int a, b, c, d, e, k;
cin >> a >> b >> c >> d >> e >> k;
if (e - a <= k) {
cout << "Yay!" << endl;
}
else cout << ":(" << endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,*_,e,k=map(int,open(0))
print([":(","Yay!"][e-a<=k])
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a = [int(input()) for _ in range(5)]
k = int(input())
print(':(' if k < max(a)-min(a) else 'Yay!') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
for(int i = 0; i < 3; i++){
int d = sc.nextInt();
}
int y = sc.nextInt();
int n = sc.nextInt();
if(y - x > n){
System.out.println(":(");
}else{
System.out.println("Yay!");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
int e=sc.nextInt();
int k=sc.nextInt();
if(e-a<=k){
System.out.println("Yay!");
}
else{
System.out.println(":(");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a=[int(input())for _ in range(5)]
k=int(input())
print("Yay!"if max(a)-min(a)<=k else":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int[] ant = new int[5];
for(int i = 0; i < 5; i++) {
ant[i] = sc.nextInt();
}
int k = sc.nextInt();
boolean isCom = true;
for(int i = 0; i < 5; i++) {
for(int j = i + 1; j < 5; j++) {
if(Math.abs(ant[i] - ant[j]) > k) {
isCom = false;
}
}
}
System.out.println(isCom ? "Yay!" : ":(");
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(); // input Integer
// String a = sc.next(); // input String
int d=0;
for (int i=1; i<=4; i++){
d=sc.nextInt();
}
int k=sc.nextInt();
if (d-a>k){
System.out.println(":(");
} else {
System.out.println("Yay!");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
int main() {
int a, b, c, d, e, k;
std::cin >> a >> b >> c >> d >> e >> k;
std::cout << (e-a > k ? ":(" : "Yay!") << std::endl;
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main(void){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a<=k) cout<<"Yay!"<<endl;
else cout<<":("<<endl;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] data = new int[5];
for(int i = 0;i < 5;i++) {
data[i] = sc.nextInt();
}
int k = sc.nextInt();
for(int i = 0;i < 5;i++) {
for(int j = 0;j < 5;j ++) {
if(Math.abs(data[i] - data[j]) > k) {
System.out.println(":(");
return;
}
}
}
System.out.println("Yay!");
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | l = [int(input()) for _ in range(5)]
k = int(input())
print('Yay!' if k >= l[4] - l[0] else ':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int array[] = new int[5];
for(int i = 0;i<5;i++){
array[i] = sc.nextInt();
}
int k = sc.nextInt();
Arrays.sort(array);
if((array[4]-array[0])<=k){
System.out.println("Yay!");
}else{
System.out.println(":(");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int num[] = new int[5];
for(int i=0; i<=4; i++){
num[i] = scanner.nextInt();
}
int k = scanner.nextInt();
for(int i=0; i<num.length; i++){
if(num[num.length-i-1] - num[i] > k){
System.out.println(":(");
return;
}
}
System.out.println("Yay!");
return;
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int a[5],k;
cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
(a[4] - a[0] > k)? cout << ":(\n" : cout << "Yay!\n";
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
sc.nextInt();
sc.nextInt();
sc.nextInt();
int e = sc.nextInt();
int k = sc.nextInt();
String s = (e -a <= k) ? "Yay!" : ":(" ;
System.out.println(s);
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, k;
cin >> a >> b >> c >> d >> e >> k;
if (e-a<=k) cout << "Yay!\n";
else cout << ":(\n";
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e,k=map(int,open(0))
print((":(","Yay!")[e-a<=k]) | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | li = [int(input()) for i in range(6)]
print("Yay!" if li[4]-li[0] <= li[5] else ":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | l = [int(input()) for _ in range(5)]
k = int(input())
print([':(', 'Yay!'][k >= l[4] - l[0]])
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a<=k){cout<<"Yay!"<<endl;}
else{cout<<":("<<endl;}
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, k;
cin >> a >> b >> c >> d >> e >> k;
cout << (e - a > k ? ":(" : "Yay!");
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e,k = [int(input()) for _ in range(6)]
result = "Yay!" if e-a<=k else ":("
print(result) | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
int main(){
using namespace std;
long a, b, c, d, e, k;
cin >> a >> b >> c >> d >> e >> k;
puts(a + k < e ? ":(" : "Yay!");
return 0;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] an = new int[5];
for(int i = 0; i < 5; i++) {
an[i] = sc.nextInt();
}
int k = sc.nextInt();
String ans = ":(";
sc.close();
if (an[4] - an[0] <= k) {
ans = "Yay!";
}
System.out.println(ans);
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
if(e-a>f)
cout<<":("<<endl;
else
cout<<"Yay!"<<endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a, b, c, d, e, k = [int(input()) for i in range(6)]
print("Yay!" if (e-a)<=k else ":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a=[int(input()) for _ in range(5)]
k=int(input())
print('Yay!' if max(a)-min(a)<=k else ':(')
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | x=[int(input()) for _ in range(5)]
k=int(input())
print(":(" if x[-1]-x[0]>k else "Yay!") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
b=e-a;
if(b>k)
cout<<":("<<endl;
else
cout<<"Yay!"<<endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main(){
int a, b, c, d, e, k;
cin>>a>>b>>c>>d>>e>>k;
string out = "Yay!";
if(e-a>k)out = ":(";
cout<<out;
return 0;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
cin>>k;
if(e-a<=k)cout<<"Yay!";
else cout<<":(";
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,k;cin>>a>>b>>c>>d>>e>>k;
cout << ( (max({a,b,c,d,e})-min({a,b,c,d,e})<=k) ? "Yay!" : ":(" )<<endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Integer[] array = new Integer[5];
for(int i = 0; i < 5; ++i) {
int tmp = sc.nextInt();
array[i] = tmp;
}
int k = Integer.parseInt(sc.next());
if(array[4] - array[0] <= k) System.out.println("Yay!");
else System.out.println(":(");
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int k = sc.nextInt();
if(e - a <= k)System.out.println("Yay!");
else System.out.println(":(");
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e,k = list(int(input()) for _ in range(6))
if e-a <= k:
print('Yay!')
else:
print(':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,k;
int main(){
cin >> a >> b >> c >> d >> e >> k;
cout << (e-a>k ? ":(" : "Yay!") << endl;
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | n=[]
for i in range(6):
n.append(int(input()))
print('Yay!' if n[4] - n[0] <= n[5] else ':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner stdIn = new Scanner(System.in);
int a = stdIn.nextInt();
int b = stdIn.nextInt();
int c = stdIn.nextInt();
int d = stdIn.nextInt();
int e = stdIn.nextInt();
int k = stdIn.nextInt();
if(e-a > k) System.out.println(":(");
else System.out.println("Yay!");
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
final class Main {
public static void main(String args[]){
Scanner stdIn = new Scanner(System.in);
int a, b, c, d, e, k;
a = stdIn.nextInt();
b = stdIn.nextInt();
c = stdIn.nextInt();
d = stdIn.nextInt();
e = stdIn.nextInt();
k = stdIn.nextInt();
if(e-a <= k){
System.out.print("Yay!");
}else{
System.out.print(":(");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
int c = Integer.parseInt(sc.next());
int d = Integer.parseInt(sc.next());
int e = Integer.parseInt(sc.next());
int k = Integer.parseInt(sc.next());
sc.close();
if(e - a <= k) {
System.out.println("Yay!");
}else {
System.out.println(":(");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a=[int(input())for i in range(5)];print(":("if max(a)-min(a)>int(input()) else"Yay!") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a = [int(input()) for _ in range(5)]
k = int(input())
print("Yay!" if a[-1] - a[0] <= k else ":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[5];
for (int i = 0; i < 5; i++) {
arr[i] = sc.nextInt();
}
int k = sc.nextInt();
if (arr[4] - arr[0] > k) {
System.out.println(":(");
} else {
System.out.println("Yay!");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,*_,e,k=[int(input())for x in' '*6];print(['Yay!',':('][e-a>k]) | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | l=[int(input()) for _ in range(5)]
print("Yay!" if max(l)-min(l)<=int(input()) else ":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<stdio.h>
int a,b,c,d,e,k;
int main()
{
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
if(e-a>k)puts(":(");
else puts("Yay!");
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <iostream>
using namespace std;
int main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a>k){
cout<<":(";
} else {
cout<<"Yay!";
}}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <cstdio>
int main(){
int a[6];
for (int i=0; i<6; i++){
scanf("%d", &a[i]);
}
if (a[4]-a[0]<=a[5])puts("Yay!");
else puts(":(");
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | I = list(map(int, open(0).read().split()))
print("Yay!" if I[4] - I[0] <= I[5] else ":(") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
int C = sc.nextInt();
int D = sc.nextInt();
int E = sc.nextInt();
int F = sc.nextInt();
System.out.println((E-A<=F)?"Yay!":":(");
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | s=[int(input()) for i in range(6)]
if s[4]-s[0]>s[5]:
print(':(')
else:
print('Yay!') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | A=[int(input()) for _ in range(5)]
print("Yay!" if (A[-1]-A[0])<=int(input()) else ":(")
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,k;cin>>a>>b>>c>>d>>e>>k;
if(e-a>k)cout<<":(";
else cout<<"Yay!";
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int k = sc.nextInt();
if (e - a > k) {
System.out.println(":(");
} else {
System.out.println("Yay!");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int k = sc.nextInt();
if (e - a <= k) {
System.out.println("Yay!");
} else {
System.out.println(":(");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e,k=map(int,open(0).read().split())
print(':(' if k < (e-a) else 'Yay!') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e=[int(input()) for i in range(5)]
print('Yay!' if e-a<=int(input()) else ':(')
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a = [int(input()) for i in range(6)]
print(":(" if (a[4]-a[0] > a[5]) else "Yay!") | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<iostream>
using namespace std;
int main()
{
int a[5],k;
for(int i=0;i<5;i++)
cin>>a[i];
cin>>k;
if(a[4]-a[0]<=k)
cout<<"Yay!";
else cout<<":(";
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | L=[ input() for i in range(5)]
k=input()
for x in L:
for y in L:
if k<abs(x-y):
print ":("
quit()
else:
print "Yay!"
| PYTHON |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] s = new int[5];
// 整数の入力
s[0] = sc.nextInt();
s[1] = sc.nextInt();
s[2] = sc.nextInt();
s[3] = sc.nextInt();
s[4] = sc.nextInt();
int k = sc.nextInt();
boolean flg = true;
for(int n=0;n<4&&flg;n++){
for(int m=n+1;m<5&&flg;m++){
if(s[m]-s[n]>k)flg=false;
}
}
// 出力
System.out.println(flg?"Yay!":":(");
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
signed main(){
int a,b,c;cin>>a>>b>>b>>b>>b>>c;
if(b-a<=c)puts("Yay!");
else puts(":(");
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | def int_raw():
return int(input())
def ss_raw():
return input().split()
def ints_raw():
return list(map(int, ss_raw()))
a = int_raw()
b = int_raw()
c = int_raw()
d = int_raw()
e = int_raw()
k = int_raw()
if e - a <= k:
print('Yay!')
else:
print(':(')
| PYTHON |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(1000000)
INF = 10 ** 18
MOD = 10 ** 9 + 7
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
print "Yay!" if e - a <= k else ":(" | PYTHON |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | A = [int(input()) for _ in range(5)]
k = int(input())
print('Yay!' if A[4] - A[0] <= k else ':(') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,b,c,d,e,k=[int(input())for _ in range(6)]
print(':(' if e-a>k else 'Yay!') | PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String args[]) {
int[] a = new int[6];
for (int i=0; i < 6; i++)
a[i] = sc.nextInt();
System.out.println(a[5] >= a[4] - a[0] ? "Yay!" : ":(");
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int[] array = new int[6];
for (int i = 0; i < array.length; i++) {
array[i] = reader.nextInt();
}
if (array[4] - array[0] <= array[5])
System.out.println("Yay!");
else {
System.out.println(":(");
}
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
int k;
cin>>k;
if(e-a<=k)cout<<"Yay!";
else cout<<":(";
return 0;
}
| CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int d = scan.nextInt();
int e = scan.nextInt();
int k = scan.nextInt();
System.out.println(e - a <= k ? "Yay!" : ":(");
scan.close();
}
} | JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | // A - Five Antennas
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,K; cin>>a>>b>>c>>d>>e>>K;
cout<< (e-a>K?":(":"Yay!") <<endl;
} | CPP |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | n = [int(input()) for i in range(6)]
print('Yay!' if (n[4]-n[0]) <= n[5] else ':(')
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a = [int(input()) for _ in range(6)]
if a[4]-a[0] <= a[5]:
print('Yay!')
else:
print(':(')
| PYTHON3 |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int k = sc.nextInt();
if ((e - a) > k) {
System.out.println(":(");
}
else {
System.out.println("Yay!");
}
}
}
| JAVA |
p03075 AtCoder Beginner Contest 123 - Five Antennas | In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
Constraints
* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e
Input
Input is given from Standard Input in the following format:
a
b
c
d
e
k
Output
Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.
Examples
Input
1
2
4
8
9
15
Output
Yay!
Input
15
18
26
35
36
18
Output
:( | 6 | 0 | a,*_,e,k=map(int,open(0));print('Y:a(y !'[e-a>k::2]) | PYTHON3 |
p03217 Dwango Programming Contest V - Square Rotation | Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he decided to rearrange them.
In an infinitely large two-dimensional plane, every lattice point has a soft toy on it. The coordinates (x_i,y_i) of N black rare soft toys are given. All soft toys are considered to be points (without a length, area, or volume).
He may perform the following operation arbitrarily many times:
* Put an axis-aligned square with side length D, rotate the square by 90 degrees with four soft toys on the four corners of the square. More specifically, if the left bottom corner's coordinate is (x, y), rotate four points (x,y) \rightarrow (x+D,y) \rightarrow (x+D,y+D) \rightarrow (x,y+D) \rightarrow (x,y) in this order. Each of the four corners of the square must be on a lattice point.
Let's define the scatteredness of an arrangement by the minimum side length of an axis-aligned square enclosing all black rare soft toys. Black rare soft toys on the edges or the vertices of a square are considered to be enclosed by the square.
Find the minimum scatteredness after he performs arbitrarily many operations.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq D \leq 1000
* 0 \leq x_i, y_i \leq 10^9
* Given coordinates are pairwise distinct
* All numbers given in input are integers
Input
Input is given from Standard Input in the following format:
N D
x_1 y_1
:
x_N y_N
Output
Print the answer.
Examples
Input
3 1
0 0
1 0
2 0
Output
1
Input
19 2
1 3
2 3
0 1
1 1
2 1
3 1
4 4
5 4
6 4
7 4
8 4
8 3
8 2
8 1
8 0
7 0
6 0
5 0
4 0
Output
4
Input
8 3
0 0
0 3
3 0
3 3
2 2
2 5
5 2
5 5
Output
4 | 6 | 0 | #include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;
ll num[1010][1010];
ll high[2010][2010];
ll middle[2010][2010];
ll low[2010][2010];
ll db[1010];
int main() {
ll N, D;
cin >> N >> D;
for (int i = 0; i < 1010; i++) {
fill(num[i], num[i] + 1010, 0);
}
for (int i = 0; i < 1010; i++) {
db[i] = i * i;
}
for (int i = 0; i < N; i++) {
ll x, y;
cin >> x >> y;
x = x % D;
y = y % D;
num[x][y]++;
}
ll maxnum = 0;
for (int i = 0; i < D; i++) {
for (int j = 0; j < D; j++) {
maxnum = max(maxnum, num[i][j]);
}
}
ll sz = lower_bound(db, db + 1010, maxnum) - db;
//cout << sz << endl;
ll hi = sz * D - 1;
ll lo = (sz - 1) * D - 1;
for (int i = 0; i < 2010; i++) {
fill(high[i], high[i] + 2010, 0);
fill(middle[i], middle[i] + 2010, 0);
fill(low[i], low[i] + 2010, 0);
}
ll highnum = sz * sz;
ll middlenum = sz * (sz - 1);
ll lownum = (sz - 1) * (sz - 1);
for (int i = 0; i < D; i++) {
for (int j = 0; j < D; j++) {
if (num[i][j] > highnum) {
high[i + 1][j + 1]++;
high[i + D + 1][j + 1]++;
high[i + 1][j + D + 1]++;
high[i + D + 1][j + D + 1]++;
}
if (num[i][j] > middlenum) {
middle[i + 1][j + 1]++;
middle[i + D + 1][j + 1]++;
middle[i + 1][j + D + 1]++;
middle[i + D + 1][j + D + 1]++;
}
if (num[i][j] > lownum) {
low[i + 1][j + 1]++;
low[i + D + 1][j + 1]++;
low[i + 1][j + D + 1]++;
low[i + D + 1][j + D + 1]++;
}
}
}
for (int i = 0; i < 2 * D + 1; i++) {
for (int j = 1; j < 2 * D + 1; j++) {
high[i][j] += high[i][j - 1];
middle[i][j] += middle[i][j - 1];
low[i][j] += low[i][j - 1];
}
}
for (int i = 1; i < 2 * D + 1; i++) {
for (int j = 0; j < 2 * D + 1; j++) {
high[i][j] += high[i - 1][j];
middle[i][j] += middle[i - 1][j];
low[i][j] += low[i - 1][j];
}
}
while (hi - lo > 1) {
ll mid = (hi + lo) / 2;
//ll a = mid / D;
ll b = mid % D + 1;
bool ok = false;
for (int i = 0; i < D; i++) {
for (int j = 0; j < D; j++) {
// bool subok = true;
// for (int k = 0; k < D; k++) {
// for (int l = 0; l < D; l++) {
// ll numkl;
// if ((i <= k && k <= i + b) || (i <= k + D && k + D <= i + b)) {
// if ((j <= l && l <= j + b) || (j <= l + D && l + D <= j + b)) {
// numkl = (a + 1) * (a + 1);
// } else {
// numkl = a * (a + 1);
// }
// } else {
// if ((j <= l && l <= j + b) || (j <= l + D && l + D <= j + b)) {
// numkl = a * (a + 1);
// } else {
// numkl = a * a;
// }
// }
// if (num[k][l] > numkl) {
// subok = false;
// break;
// }
// }
// if (!subok) {
// break;
// }
// }
// if (subok) {
// ok = true;
// break;
// }
ll highover = high[i + b][j + b] - high[i][j + b] - high[i + b][j] + high[i][j];
ll middleover1 = middle[i + D][j + b] - middle[i + b][j + b]
- middle[i + D][j] + middle[i + b][j];
ll middleover2 = middle[i + b][j + D] - middle[i][j + D]
- middle[i + b][j + b] + middle[i][j + b];
ll lowover = low[i + D][j + D] - low[i + b][j + D]
- low[i + D][j + b] + low[i + b][j + b];
//cout << mid << " " << b;
//cout << " " << highover << " " << middleover1 << " " << middleover2 << " " << lowover << endl;
if (highover == 0 && middleover1 == 0 && middleover2 == 0 && lowover == 0) {
ok = true;
break;
}
}
if (ok) {
break;
}
}
if (ok) {
hi = mid;
} else {
lo = mid;
}
}
cout << hi << endl;
}
| CPP |
p03217 Dwango Programming Contest V - Square Rotation | Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he decided to rearrange them.
In an infinitely large two-dimensional plane, every lattice point has a soft toy on it. The coordinates (x_i,y_i) of N black rare soft toys are given. All soft toys are considered to be points (without a length, area, or volume).
He may perform the following operation arbitrarily many times:
* Put an axis-aligned square with side length D, rotate the square by 90 degrees with four soft toys on the four corners of the square. More specifically, if the left bottom corner's coordinate is (x, y), rotate four points (x,y) \rightarrow (x+D,y) \rightarrow (x+D,y+D) \rightarrow (x,y+D) \rightarrow (x,y) in this order. Each of the four corners of the square must be on a lattice point.
Let's define the scatteredness of an arrangement by the minimum side length of an axis-aligned square enclosing all black rare soft toys. Black rare soft toys on the edges or the vertices of a square are considered to be enclosed by the square.
Find the minimum scatteredness after he performs arbitrarily many operations.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq D \leq 1000
* 0 \leq x_i, y_i \leq 10^9
* Given coordinates are pairwise distinct
* All numbers given in input are integers
Input
Input is given from Standard Input in the following format:
N D
x_1 y_1
:
x_N y_N
Output
Print the answer.
Examples
Input
3 1
0 0
1 0
2 0
Output
1
Input
19 2
1 3
2 3
0 1
1 1
2 1
3 1
4 4
5 4
6 4
7 4
8 4
8 3
8 2
8 1
8 0
7 0
6 0
5 0
4 0
Output
4
Input
8 3
0 0
0 3
3 0
3 3
2 2
2 5
5 2
5 5
Output
4 | 6 | 0 | #include <bits/stdc++.h>
using namespace std;
const int MXD = 1e3 + 10;
int n, d;
int large[MXD + MXD][MXD + MXD], cntlarge;
int small[MXD + MXD][MXD + MXD], cntsmall;
int cnt[MXD][MXD];
int sumlarge(int sx, int sy, int ex, int ey)
{
if (sx == 0 && sy == 0)
{
return large[ex][ey];
}
if (sx == 0)
{
return large[ex][ey] - large[ex][sy - 1];
}
if (sy == 0)
{
return large[ex][ey] - large[sx - 1][ey];
}
return large[ex][ey] - large[ex][sy - 1] - large[sx - 1][ey] + large[sx - 1][sy - 1];
}
int sumsmall(int sx, int sy, int ex, int ey)
{
if (sx == 0 && sy == 0)
{
return small[ex][ey];
}
if (sx == 0)
{
return small[ex][ey] - small[ex][sy - 1];
}
if (sy == 0)
{
return small[ex][ey] - small[sx - 1][ey];
}
return small[ex][ey] - small[ex][sy - 1] - small[sx - 1][ey] + small[sx - 1][sy - 1];
}
bool check(int x)
{
bool flag;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
flag = true;
int tmp = sumlarge(i, j, i + x, j + x);
if (tmp < cntlarge)
{
flag = false;
}
if (sumsmall(0, j, d - 1, j + x) + sumsmall(i, 0, i + x, d - 1) - sumsmall(i, j, i + x, j + x) < cntsmall)
{
flag = false;
}
if (flag)
return true;
}
}
return false;
}
int main ()
{
scanf("%d%d", &n, &d);
memset(cnt, 0, sizeof(cnt));
for (int i = 1; i <= n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
cnt[x % d][y % d]++;
}
int maxcnt = 0;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
maxcnt = max(maxcnt, cnt[i][j]);
// cout << cnt[i][j] << " ";
}
// cout << endl;
}
int a = ceil(sqrt(maxcnt)) - 1;
cntlarge = cntsmall = 0;
memset(small, 0, sizeof(small));
memset(large, 0, sizeof(large));
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (cnt[i][j] <= a * (a + 1) && cnt[i][j] > a * a)
{
small[i][j] = true;
cntsmall++;
}
else if (cnt[i][j] > a * (a + 1))
{
large[i][j] = true;
cntlarge++;
}
}
}
for (int i = 0; i < d + d; i++)
for (int j = 0; j < d + d; j++)
if (!(i < d && j < d))
{
small[i][j] = small[i % d][j % d];
large[i][j] = large[i % d][j % d];
}
for (int i = 0; i < d + d; i++)
for (int j = 0; j < d + d; j++)
{
if (i > 0 && j > 0)
{
small[i][j] = small[i - 1][j] + small[i][j - 1] - small[i - 1][j - 1] + small[i][j];
large[i][j] = large[i - 1][j] + large[i][j - 1] - large[i - 1][j - 1] + large[i][j];
}
else if (i > 0)
{
small[i][j] = small[i - 1][j] + small[i][j];
large[i][j] = large[i - 1][j] + large[i][j];
}
else if (j > 0)
{
small[i][j] = small[i][j - 1] + small[i][j];
large[i][j] = large[i][j - 1] + large[i][j];
}
}
// cout << "large = " << cntlarge << endl;
// cout << "small = " << cntsmall << endl;
int l = 0, r = d - 1, mid;
if (check(0))
{
r = 0;
}
else
{
while (l < r - 1)
{
mid = l + r >> 1;
if (check(mid))
{
r = mid;
}
else
{
l = mid;
}
}
}
printf("%d", a * d + r);
return 0;
} | CPP |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.