Submission #1000878

# Submission time Handle Problem Language Result Execution time Memory
1000878 2024-06-18T10:53:31 Z 변재우(#10901) Closing Time (IOI23_closing) C++17
0 / 100
38 ms 9952 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int Nmax=3010;
ll S[Nmax];

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    X++, Y++;
    ll ans=0;
    fill(S+1, S+N+1, 0);
    for(int i=2; i<=N; i++) S[i]=S[i-1]+W[i-2];
    ll sum=0;
    for(int r=X; r<=N; r++) {
        vector<pair<ll, bool>> V;
        ll tsum=sum, cnt=0, sum2=0, p=0;
        for(int i=X-1; i>=1; i--) V.push_back({S[X]-S[i], false});
        for(int i=Y+1; i<=N; i++) {
            if(i>r) V.push_back({S[i]-S[Y], false});
            else cnt++;
        }
        sort(V.begin(), V.end());
        while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=V[p++].first;
        for(int l=Y; l>=1; l--) {
            sum+=(S[Y]-S[l]);
            if(X<=l && l<=r) sum-=min(S[Y]-S[l], S[l]-S[X]);
            if(l<X) (*(upper_bound(V.begin(), V.end(), make_pair(S[X]-S[l], false))-1)).second=true, cnt++;
            while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=(1-V[p].second)*V[p].first, cnt-=V[p++].second;
            while(p>0 && sum+sum2>K) sum2-=(1-V[--p].second)*V[p].first, cnt+=V[p].second;
            if(sum<=K) ans=max(ans, r-X+1+Y-l+1+cnt+p);
        }
        sum=tsum+S[r+1]-S[X];
    }
    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:24:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=V[p++].first;
      |               ~^~~~~~~~~
closing.cpp:29:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=(1-V[p].second)*V[p].first, cnt-=V[p++].second;
      |                   ~^~~~~~~~~
closing.cpp:30:49: warning: operation on 'p' may be undefined [-Wsequence-point]
   30 |             while(p>0 && sum+sum2>K) sum2-=(1-V[--p].second)*V[p].first, cnt+=V[p].second;
      |                                                 ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 Runtime error 38 ms 9952 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '35'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '35'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '35'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 348 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 348 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 348 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 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -