# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
27785 |
2017-07-14T06:00:50 Z |
서규호(#1160) |
Sparklers (JOI17_sparklers) |
C++14 |
|
2000 ms |
2800 KB |
#include <bits/stdc++.h>
#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define left leftt
#define right rightt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007
using namespace std;
int N,M,ans; lld T;
lld a[100002];
bool flag; lld memo;
void dfs(lld l,lld r,lld s,lld e){
lld X = memo;
if(r-l == N-1 || flag){
flag = true;
return;
}
lld cnt = r-l+1;
if(r != N && max(s-X,a[r+1]-X*cnt) <= min(e+X,a[r+1]+X*cnt)){
dfs(l,r+1,max(s-X,a[r+1]-X*cnt),min(e+X,a[r+1]+X*cnt));
}
if(l != 1 && max(s-X,a[l-1]-X*cnt) <= min(e+X,a[l-1]+X*cnt)){
dfs(l-1,r,max(s-X,a[l-1]-X*cnt),min(e+X,a[l-1]+X*cnt));
}
}
bool can(lld X){
X *= T; X %= Mod;
int l,r; lld cnt;
lld s,e;
l = r = M; cnt = 1;
s = e = a[M];
memo = X;
/*while(r-l != N-1){
if(r != N && max(s-X,a[r+1]-X*cnt) <= min(e+X,a[r+1]+X*cnt)){
s = max(s-X,a[r+1]-X*cnt);
e = min(e+X,a[r+1]+X*cnt);
r++;
}else if(l != 1 && max(s-X,a[l-1]-X*cnt) <= min(e+X,a[l-1]+X*cnt)){
s = max(s-X,a[l-1]-X*cnt);
e = min(e+X,a[l-1]+X*cnt);
l--;
}else return false;
s = max((lld)0,s); e = min(e,(lld)Mod);
cnt++;
}*/
flag = false;
dfs(l,r,s,e);
return flag;
}
int main(){
scanf("%d %d %lld",&N,&M,&T);
for(int i=1; i<=N; i++){
scanf("%lld",&a[i]);
}
int l,r;
l = 0; r = a[N];
while(l <= r){
int m = (l+r)/2;
if(can(m)){
ans = m;
r = m-1;
}else l = m+1;
}
printf("%d\n",ans);
return 0;
}
Compilation message
sparklers.cpp: In function 'bool can(long long int)':
sparklers.cpp:38:15: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
int l,r; lld cnt;
^
sparklers.cpp: In function 'int main()':
sparklers.cpp:65:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %lld",&N,&M,&T);
^
sparklers.cpp:67:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&a[i]);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
0 ms |
2800 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
0 ms |
2800 KB |
Output is correct |
5 |
Correct |
0 ms |
2800 KB |
Output is correct |
6 |
Correct |
0 ms |
2800 KB |
Output is correct |
7 |
Correct |
0 ms |
2800 KB |
Output is correct |
8 |
Correct |
0 ms |
2800 KB |
Output is correct |
9 |
Correct |
0 ms |
2800 KB |
Output is correct |
10 |
Correct |
0 ms |
2800 KB |
Output is correct |
11 |
Correct |
0 ms |
2800 KB |
Output is correct |
12 |
Correct |
0 ms |
2800 KB |
Output is correct |
13 |
Correct |
0 ms |
2800 KB |
Output is correct |
14 |
Correct |
0 ms |
2800 KB |
Output is correct |
15 |
Correct |
0 ms |
2800 KB |
Output is correct |
16 |
Correct |
0 ms |
2800 KB |
Output is correct |
17 |
Correct |
0 ms |
2800 KB |
Output is correct |
18 |
Correct |
0 ms |
2800 KB |
Output is correct |
19 |
Correct |
0 ms |
2800 KB |
Output is correct |
20 |
Correct |
0 ms |
2800 KB |
Output is correct |
21 |
Correct |
0 ms |
2800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
0 ms |
2800 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
0 ms |
2800 KB |
Output is correct |
5 |
Correct |
0 ms |
2800 KB |
Output is correct |
6 |
Correct |
0 ms |
2800 KB |
Output is correct |
7 |
Correct |
0 ms |
2800 KB |
Output is correct |
8 |
Correct |
0 ms |
2800 KB |
Output is correct |
9 |
Correct |
0 ms |
2800 KB |
Output is correct |
10 |
Correct |
0 ms |
2800 KB |
Output is correct |
11 |
Correct |
0 ms |
2800 KB |
Output is correct |
12 |
Correct |
0 ms |
2800 KB |
Output is correct |
13 |
Correct |
0 ms |
2800 KB |
Output is correct |
14 |
Correct |
0 ms |
2800 KB |
Output is correct |
15 |
Correct |
0 ms |
2800 KB |
Output is correct |
16 |
Correct |
0 ms |
2800 KB |
Output is correct |
17 |
Correct |
0 ms |
2800 KB |
Output is correct |
18 |
Correct |
0 ms |
2800 KB |
Output is correct |
19 |
Correct |
0 ms |
2800 KB |
Output is correct |
20 |
Correct |
0 ms |
2800 KB |
Output is correct |
21 |
Correct |
0 ms |
2800 KB |
Output is correct |
22 |
Correct |
0 ms |
2800 KB |
Output is correct |
23 |
Execution timed out |
2000 ms |
2800 KB |
Execution timed out |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2800 KB |
Output is correct |
2 |
Correct |
0 ms |
2800 KB |
Output is correct |
3 |
Correct |
0 ms |
2800 KB |
Output is correct |
4 |
Correct |
0 ms |
2800 KB |
Output is correct |
5 |
Correct |
0 ms |
2800 KB |
Output is correct |
6 |
Correct |
0 ms |
2800 KB |
Output is correct |
7 |
Correct |
0 ms |
2800 KB |
Output is correct |
8 |
Correct |
0 ms |
2800 KB |
Output is correct |
9 |
Correct |
0 ms |
2800 KB |
Output is correct |
10 |
Correct |
0 ms |
2800 KB |
Output is correct |
11 |
Correct |
0 ms |
2800 KB |
Output is correct |
12 |
Correct |
0 ms |
2800 KB |
Output is correct |
13 |
Correct |
0 ms |
2800 KB |
Output is correct |
14 |
Correct |
0 ms |
2800 KB |
Output is correct |
15 |
Correct |
0 ms |
2800 KB |
Output is correct |
16 |
Correct |
0 ms |
2800 KB |
Output is correct |
17 |
Correct |
0 ms |
2800 KB |
Output is correct |
18 |
Correct |
0 ms |
2800 KB |
Output is correct |
19 |
Correct |
0 ms |
2800 KB |
Output is correct |
20 |
Correct |
0 ms |
2800 KB |
Output is correct |
21 |
Correct |
0 ms |
2800 KB |
Output is correct |
22 |
Correct |
0 ms |
2800 KB |
Output is correct |
23 |
Execution timed out |
2000 ms |
2800 KB |
Execution timed out |
24 |
Halted |
0 ms |
0 KB |
- |