#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std ;
int count_mushrooms(int n) {
std::vector<int> m;
vector <int> A, B ;
A.push_back ( 0 ) ;
int id = 0 ;
int ans = 1;
for ( int i = 1 ; i < n ; ++i ) {
m.push_back ( i ) ;
if ( A.size() > B.size() )
m.push_back ( A[id] ) ;
else m.push_back ( B[id] ) ;
id++ ;
if ( m.size() == max ( A.size(), B.size() ) * 2 ) {
if ( A.size() > B.size() ) {
int x = use_machine (m) ;
if ( x % 2 ) B.push_back (m[0]);
else A.push_back (m[0]) ;
ans += A.size() - (x+1)/2 ;
}
else {
int x = use_machine (m) ;
if ( x % 2 ) A.push_back (m[0]);
else B.push_back (m[0]) ;
ans += (x+1)/2 ;
}
m.clear() ;
id = 0 ;
}
}
if ( m.size() ) {
if ( A.size() > B.size() ) ans += m.size()/2 - (use_machine(m)+1)/2 ;
else ans += (use_machine(m)+1)/2 ;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
Answer is not correct. |
6 |
Halted |
0 ms |
0 KB |
- |