Submission #979934

# Submission time Handle Problem Language Result Execution time Memory
979934 2024-05-11T16:29:31 Z vjudge1 Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 8168 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--){
                if(l>j)ans+=suf[l]- suf[y];
                else{
                    if(l>x){ans+=max(suf[l]-suf[y], pre[l] - pre[x]);ans-=min(suf[l]-suf[y], pre[l] - pre[x]);}
                    else{ans+=suf[l]-suf[y];ans-=suf[l] - suf[x];}
                }
                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);
                }
                for(ll lk=y;lk<=n-1;lk++)
                    if(j<lk)ans-=pre[lk] - pre[y];
            }
            for(ll l =y;l>=0;l--){
                if(l>j)ans-=suf[l]- suf[y];
                else{
                    if(l>x){ans-=max(suf[l]-suf[y], pre[l] - pre[x]);ans+=min(suf[l]-suf[y], pre[l] - pre[x]);}
                    else{ans-=suf[l]-suf[y];ans+=suf[l]-suf[x];}
                }
            }
            // cout<<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 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 8168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '33'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '33'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '33'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -