FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/src/convention.java at master · javaarchive/Java · GitHub
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
javaarchive
/
Java
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
3
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
src
/
convention.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (48 loc) · 1.28 KB
Breadcrumbs
Java
/
src
/
convention.java
Copy path
File metadata and controls
50 lines (48 loc) · 1.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import
java
.
io
.*;
import
java
.
util
.*;
public
class
convention
{
static
int
[]
time
=
new
int
[
100000
];
static
int
N
,
M
,
C
;
public
static
boolean
pos
(
int
waittime
) {
int
w
=
1
;
int
fa
=
time
[
0
];
int
firstpos
=
0
;
// Default
for
(
int
i
=
1
;
i
<
N
;
i
++) {
if
(
time
[
i
] -
fa
>
waittime
|| (
i
+
1
-
firstpos
>
C
)){
w
+=
1
;
fa
=
time
[
i
];
firstpos
=
i
;
}
}
return
(
w
<=
M
);
}
static
int
bs
(
int
low
,
int
high
)
{
if
(
low
==
high
)
return
low
;
if
(
low
+
1
==
high
)
{
if
(
pos
(
low
))
return
low
;
return
high
;
}
int
mid
= (
low
+
high
)/
2
;
if
(
pos
(
mid
))
return
bs
(
low
,
mid
);
else
return
bs
(
mid
+
1
,
high
);
}
// Power counter 123456789
static
int
MAX_POSSIBLE
=
1000000000
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
BufferedReader
f
=
new
BufferedReader
(
new
FileReader
(
"convention.in"
));
// TODO Auto-generated method stub
StringTokenizer
st
=
new
StringTokenizer
(
f
.
readLine
());
N
=
Integer
.
parseInt
(
st
.
nextToken
());
M
=
Integer
.
parseInt
(
st
.
nextToken
());
C
=
Integer
.
parseInt
(
st
.
nextToken
());
st
=
new
StringTokenizer
(
f
.
readLine
());
for
(
int
i
=
0
;
i
<
N
;
i
++) {
time
[
i
] =
Integer
.
parseInt
(
st
.
nextToken
());
}
f
.
close
();
PrintWriter
pw
=
new
PrintWriter
(
new
FileWriter
(
"convention.out"
));
pw
.
print
(
bs
(
0
,
MAX_POSSIBLE
));
pw
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL