Contest Duration: - (local time) (100 minutes) Back to Home

Submission #19636931

Source Code Expand

Copy
```#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,K;
int A[101010];
int NG[101010];
long double dp[202020],S[202020];

long double hoge(double v) {
int i;

for(i=N-1;i>=0;i--) {
if(NG[i]) {
dp[i]=v;
}
else {
dp[i]=1+(S[i+1]-S[i+1+M])/M;
}
S[i]=S[i+1]+dp[i];
}
return dp[0];
}

void solve() {
int i,j,k,l,r,x,y; string s;

cin>>N>>M>>K;
int p=-1,cur=0;
FOR(i,K) {
cin>>A[i];
if(p+1!=A[i]) cur=0;
p=A[i];
NG[A[i]]=1;
cur++;
if(cur==M) return _P("-1\n");
}

long double L=0,R=1e10;
FOR(i,300) {
long double M=(L+R)/2;
if(hoge(M)>M) L=M;
else R=M;
}
_P("%.12lf\n",(double)L);

}

int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
```

#### Submission Info

Submission Time 2021-01-23 22:15:44+0900 F - Sugoroku2 kmjp C++ (GCC 9.2.1) 0 1455 Byte WA 321 ms 6840 KB

#### Compile Error

```./Main.cpp: In function ‘void solve()’:
./Main.cpp:39:8: warning: unused variable ‘j’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|        ^
./Main.cpp:39:10: warning: unused variable ‘k’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|          ^
./Main.cpp:39:12: warning: unused variable ‘l’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|            ^
./Main.cpp:39:14: warning: unused variable ‘r’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|              ^
./Main.cpp:39:16: warning: unused variable ‘x’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|                ^
./Main.cpp:39:18: warning: unused variable ‘y’ [-Wunused-variable]
39 |  int i,j,k,l,r,x,y; string s;
|                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
|                            ^
./Main.cpp:66:38: note: in expansion of macro ‘FOR’
66 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
|                                      ^~~
```

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
 AC × 4
 AC × 29 WA × 1
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_04.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, unreachable_01.txt, unreachable_02.txt, unreachable_03.txt, unreachable_04.txt
Case Name Status Exec Time Memory
hand_01.txt AC 303 ms 6748 KB
hand_02.txt AC 2 ms 3548 KB
hand_04.txt AC 3 ms 3716 KB
max_01.txt AC 319 ms 6764 KB
max_02.txt AC 299 ms 6700 KB
max_03.txt AC 321 ms 6732 KB
max_04.txt WA 298 ms 6764 KB
random_01.txt AC 313 ms 6840 KB
random_02.txt AC 54 ms 4176 KB
random_03.txt AC 295 ms 6664 KB
random_04.txt AC 16 ms 3688 KB
random_05.txt AC 313 ms 6800 KB
random_06.txt AC 298 ms 6580 KB
random_07.txt AC 314 ms 6752 KB
random_08.txt AC 27 ms 3824 KB
random_09.txt AC 314 ms 6820 KB
random_10.txt AC 127 ms 4808 KB
random_11.txt AC 312 ms 6760 KB
random_12.txt AC 308 ms 6772 KB
random_14.txt AC 194 ms 5584 KB
random_15.txt AC 315 ms 6840 KB
random_16.txt AC 146 ms 5032 KB
sample_01.txt AC 3 ms 3524 KB
sample_02.txt AC 2 ms 3732 KB
sample_03.txt AC 3 ms 3600 KB
sample_04.txt AC 296 ms 6812 KB
unreachable_01.txt AC 3 ms 3448 KB
unreachable_02.txt AC 3 ms 3396 KB
unreachable_03.txt AC 3 ms 3488 KB
unreachable_04.txt AC 2 ms 3468 KB