답안 #1000875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000875 2024-06-18T10:48:27 Z 변재우(#10901) 봉쇄 시간 (IOI23_closing) C++17
0 / 100
40 ms 9960 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int Nmax=3010, Nt=(1<<14);
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))).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;
      |                                                 ^~~
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 9960 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -