Submission #848542

# Submission time Handle Problem Language Result Execution time Memory
848542 2023-09-12T21:03:21 Z n3rm1n Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
2000 ms 348 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 205;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
long long n, l, a[MAXN], t[MAXN];
long long maxx = 0;
void read()
{
    cin >> n >> l;
    for (long long i = 1; i <= n; ++ i)
        cin >> a[i];
    for (long long i = 1; i <= n; ++ i)
    {
        cin >> t[i];
        maxx = max(maxx, t[i]);
    }
}
long long p[MAXN], used[MAXN], ans = 0;
void check()
{
    long long ttime = 0, on = 0, cnt = 0;
    long long go, dist;
    for (long long i = 1; i <= n; ++ i)
    {
        go = a[p[i]];
        dist = abs(go - on);
        ttime += min(dist, l - dist);
        if(ttime > maxx)break;
        if(ttime <= t[p[i]])cnt ++;
        on = go;
    }
    ans = max(ans, cnt);

}
void gen(long long pos)
{
    if(pos > n)
    {
        check();
        return;
    }
    for (long long i = 1; i <= n; ++ i)
    {
        if(!used[i])
        {
            used[i] = 1;
            p[pos] = i;
            gen(pos+1);
            used[i] = 0;
        }
    }
}
int main()
{
    speed();

    read();
    gen(1);
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 12 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Execution timed out 2029 ms 344 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 12 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Execution timed out 2029 ms 344 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 12 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Execution timed out 2029 ms 344 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 12 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Execution timed out 2029 ms 344 KB Time limit exceeded
7 Halted 0 ms 0 KB -