Submission #1000876

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

const int Nmax=3010;
ll S[Nmax];
vector<ll> C;

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), C.clear();
    for(int i=2; i<=N; i++) S[i]=S[i-1]+W[i-2];
    for(int i=1; i<=N; i++) C.push_back(abs(S[i]-S[X])), C.push_back(abs(S[i]-S[Y]));
    sort(C.begin(), C.end()); C.erase(unique(C.begin(), C.end()), C.end());
    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;
            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:27: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]
   27 |         while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=V[p++].first;
      |               ~^~~~~~~~~
closing.cpp:32: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]
   32 |             while(p<V.size() && sum+sum2+V[p].first<=K) sum2+=(1-V[p].second)*V[p].first, cnt-=V[p].second;
      |                   ~^~~~~~~~~
closing.cpp:33:49: warning: operation on 'p' may be undefined [-Wsequence-point]
   33 |             while(p>0 && sum+sum2>K) sum2-=(1-V[--p].second)*V[p].first;
      |                                                 ^~~
# 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 10068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
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 -