Submission #979943

# Submission time Handle Problem Language Result Execution time Memory
979943 2024-05-11T17:03:19 Z vjudge1 Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 8792 KB
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<ll>;using ii = pair<ll,ll>;using mii = map<ll,ll>;
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w){
    ll suf[n+1]{}, pre[n+1]{};
    fore(i,1,n)pre[i] = (i ? w[i-1] : 0) + (i ? pre[i-1] : 0);
    ffo(i,n-1)suf[i] = w[i] + suf[i+1];
    ll ans = 0, tot= 0;
    for(ll i=x;i>=0;i--){
        ans+=suf[i] - suf[x];
        for(ll j=x;j <=n-1;j++){
            ans+=pre[j]-pre[x];
            for(ll l=y;l>=0;l--){
                // cout << "WTF ! " << ans << " " << l << endl;
                if(l>j)ans+=suf[l]- suf[y];
                else{
                    if(l>x){
                        if(j>=l){
                            if(suf[l]-suf[y] > pre[l] - pre[x]){
                                ans -= pre[l] - pre[x];
                                ans+=suf[l]-suf[y];
                            }
                        }
                        else ans+= suf[l]-suf[y];
                    }
                    else{ans+=suf[l]-suf[y];if(l>=i)ans-=suf[l] - suf[x];}
                }
                // cout << "WTF " << ans << endl;
                for(ll lk=y;lk<=n-1;lk++){
                    if(j<lk)ans+=pre[lk]-pre[y];
                    // cout << i << " " << j << " " << l << " " << lk << " " << ans << endl;
                    if(ans<=k)tot = max(tot,j-i+1 + lk-l+1);
                    if(ans <= k) cout << i << " " << j << " " << l << " " << lk << endl;
                }
                for(ll lk=y;lk<=n-1;lk++)
                    if(j<lk)ans-=pre[lk] - pre[y];
                // cout << ans << endl;
            }
            for(ll l =y;l>=0;l--){
                if(l>j)ans-=suf[l]- suf[y];
                else{
                    if(l>x){
                        if(j>=l){
                            if(suf[l]-suf[y] > pre[l] - pre[x]){
                                ans += pre[l] - pre[x];
                                ans -=suf[l]-suf[y];
                            }
                        }
                        else ans -= suf[l]-suf[y];
                    }
                    else{ans-=suf[l]-suf[y];if(l>=i)ans+=suf[l] - suf[x];}
                }
            }
            // cout<<"WIN "<<  ans<<endl;
        }
        for(ll j =x;j<=n-1;j++)
            ans-=pre[j]-pre[x];
    }
    return tot;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 8792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -