Submission #940917

# Submission time Handle Problem Language Result Execution time Memory
940917 2024-03-08T02:09:49 Z LittleOrange Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
2000 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll big = 1e18;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,l;
    cin >> n >> l;
    vector<ll> x(n),t(n);
    for(ll &i : x) cin >> i;
    for(ll &i : t) cin >> i;
    vector<vector<ll>> dp(1<<n,vector<ll>(n,big));
    for(ll i = 0;i<n;i++){
        ll d = min(x[i],l-x[i]);
        if(d<=t[i]){
            dp[1<<i][i] = d;
        }
    }
    ll ans = 0;
    for(ll i = 1;i<(1<<n);i++){
        for(ll j = 0;j<n;j++) if(i>>j&1){
            for(ll k = 0;k<n;k++) if(i>>k&1^1){
                ll dd = abs(x[j]-x[k]);
                ll d = dp[i][j]+min(dd,l-dd);
                if (d<=t[k]){
                    dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],d);
                }
            }
            if(dp[i][j]<big) ans = max(ans,(ll)__builtin_popcountll(i));
        }
    }
    cout << ans << "\n";
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:22:42: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   22 |             for(ll k = 0;k<n;k++) if(i>>k&1^1){
      |                                      ~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 2 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 2 ms 856 KB Output is correct
18 Correct 7 ms 2908 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 860 KB Output is correct
21 Correct 7 ms 2908 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 16 ms 5212 KB Output is correct
24 Correct 4 ms 1484 KB Output is correct
25 Correct 7 ms 2648 KB Output is correct
26 Correct 7 ms 2652 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 16 ms 5208 KB Output is correct
30 Correct 15 ms 5212 KB Output is correct
31 Correct 7 ms 2908 KB Output is correct
32 Correct 3 ms 1372 KB Output is correct
33 Correct 16 ms 5212 KB Output is correct
34 Correct 16 ms 5232 KB Output is correct
35 Correct 16 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 2 ms 856 KB Output is correct
18 Execution timed out 3581 ms 1048576 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 2 ms 856 KB Output is correct
18 Correct 7 ms 2908 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 860 KB Output is correct
21 Correct 7 ms 2908 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 16 ms 5212 KB Output is correct
24 Correct 4 ms 1484 KB Output is correct
25 Correct 7 ms 2648 KB Output is correct
26 Correct 7 ms 2652 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 16 ms 5208 KB Output is correct
30 Correct 15 ms 5212 KB Output is correct
31 Correct 7 ms 2908 KB Output is correct
32 Correct 3 ms 1372 KB Output is correct
33 Correct 16 ms 5212 KB Output is correct
34 Correct 16 ms 5232 KB Output is correct
35 Correct 16 ms 5212 KB Output is correct
36 Execution timed out 3581 ms 1048576 KB Time limit exceeded
37 Halted 0 ms 0 KB -