답안 #680949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680949 2023-01-12T05:57:13 Z Tuanlinh123 Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
2000 ms 328 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

#define LOCALIO "C:/Users/admin/Documents/Code/"

ll n, L;
ll a[205], t[205];
ll p[205], used[205], ans;

ll dis(ll a, ll b)
{
    ll Max=max(a, b), Min=min(a, b);
    return min(Max-Min, Min-Max+L);
}

void show()
{
    ll res=0, crr=0, pos=0;
    for (ll i=1; i<=n; i++)
        crr+=dis(pos, a[p[i]]), pos=a[p[i]], res+=crr<=t[p[i]];
    ans=max(ans, res);
}

void backtrack(ll i)
{
    if (i==n+1)
    {
        show();
        return;
    }
    for (ll j=1; j<=n; j++)
        if (!used[j])
        {
            used[j]=1; p[i]=j;
            backtrack(i+1);
            used[j]=0;
        }
}

int main()
{
    #ifdef LOCAL
        freopen( LOCALIO "input.txt","r",stdin) ;
        freopen( LOCALIO "output.txt","w",stdout) ;
    #endif

    ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
//	freopen("FIBONACCI.inp","r",stdin);
//	freopen("FIBONACCI.out","w",stdout);
    cin >> n >> L;
    for (ll i=1; i<=n; i++)
        cin >> a[i];
    for (ll i=1; i<=n; i++)
        cin >> t[i];
    backtrack(1);
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 30 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Execution timed out 2090 ms 212 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 30 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Execution timed out 2090 ms 212 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 30 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Execution timed out 2090 ms 212 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 30 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Execution timed out 2090 ms 212 KB Time limit exceeded
7 Halted 0 ms 0 KB -