이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("cardgame.in" , "r" , stdin);
#define outF freopen("cardgame.out" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
//#define int ll
const int N = 3e5 + 3, M = N * 4 , MX = 2e4 + 40;
const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;
int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , 1 , -1};
int32_t main()
{
// inF;
// inF;outF;
fastio;
//Welcome back without <TAWJIHI>
int n , l ;
cin >> n >> l ;
int x[n] , t[n];
for(int i = 0 ; i < n ; i ++)cin >> x[i];
for(int i = 0 ; i < n ; i ++)cin >> t[i];
ll mx = 0 ;
for(int cnt = 0 ; cnt < (1 << n) ; cnt++){
// if(cnt != 28)continue ;
int i = 0 , j = n - 1 ;
ll tim = 0 , pos = 0 , now = 1 , ans = 0;
for(int mask = 0 ; mask < n ; mask ++){
if(cnt & (1 << mask)){
if(now == 1)
tim += x[i++] - pos;
else tim += (l - pos) + x[i++];
if(tim <= t[i - 1])ans ++ ;
pos = x[i - 1];
now = 1 ;
}
else {//debug(mask)
if(now == 1){
tim += pos;
// debug(x[j])
tim += (l - x[j--] );
}
else {
tim += pos - x[j --];
}
pos = x[j + 1];
if(tim <= t[j + 1])ans ++ ;
now = 0 ;
}
}
mx = max(mx , ans);
}
cout << mx ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |