Submission #583300

# Submission time Handle Problem Language Result Execution time Memory
583300 2022-06-25T08:21:20 Z alirezasamimi100 Bodyguard (JOI21_bodyguard) C++17
6 / 100
2511 ms 1584036 KB
/*#pragma GCC optimize("Ofast,unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")*/
/*#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")*/
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
using point=complex<double>;
#define F first
#define S second
//#define X real()
//#define Y imag()
#define pb push_back
#define mp make_pair
#define lc v<<1
#define rc v<<1|1
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define kill(x) cout << x << '\n';exit(0)
#define killshayan kill("done!")
#define killmashtali kill("Hello, World!")
const int N=3e3+10,LN=60,M=1e6+10,SQ=700,BS=737,inf=1.05e9,NSQ=N/SQ+3;
const ll INF=1e18;
const double pi=acos(-1);
const ld ep=1e-7;
const int MH=1000696969,MD=998244353,MOD=1000000007;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,greater<pii>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n, q, dp[N * 4][N * 2], tr[N * 4][N * 2][2];

int main(){
    fast_io;
    cin >> n >> q;
    for(ll i = 0; i < n; i++){
        ll t, a, b, c;
        cin >> t >> a >> b >> c;
        t *= 2;
        a *= 2;
        b *= 2;
        c /= 2;
        for(ll i = 0; a != b; i++){
            if(a < b){
                tr[t + i][a][0] = max(tr[t + i][a][0], c);
                a++;
            }else{
                tr[t + i][a][1] = max(tr[t + i][a][1], c);
                a--;
            }
        }
    }
    for(ll i = N * 4 - 2; i; i--){
        for(ll j = 1; j < N * 2; j++){
            if(j + 1 < N * 2) dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + tr[i][j][0]);
            if(j > 1) dp[i][j] = max(dp[i][j], dp[i + 1][j - 1] + tr[i][j][1]);
        }
    }
    for(ll i = 0; i < q; i++){
        ll t, a;
        cin >> t >> a;
        cout << dp[t * 2][a * 2] << '\n';
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2372 ms 1584036 KB Output is correct
2 Correct 2284 ms 1571552 KB Output is correct
3 Correct 1711 ms 754640 KB Output is correct
4 Correct 1880 ms 681036 KB Output is correct
5 Correct 2511 ms 1004392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2372 ms 1584036 KB Output is correct
2 Correct 2284 ms 1571552 KB Output is correct
3 Correct 1711 ms 754640 KB Output is correct
4 Correct 1880 ms 681036 KB Output is correct
5 Correct 2511 ms 1004392 KB Output is correct
6 Runtime error 41 ms 340 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -