Submission #1019703

# Submission time Handle Problem Language Result Execution time Memory
1019703 2024-07-11T07:53:28 Z LIF Closing Time (IOI23_closing) C++17
0 / 100
44 ms 18764 KB
#include "closing.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
long long int a[500005];
long long int b[500005];
long long int c[500005];
long long int sua[50005];
long long int sub[50005];
long long int suc[50005];

long long int kk;
int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W)
{
    
    kk = K;
    for(int i=0;i<U.size();i++)U[i]+=1;
    for(int i=0;i<V.size();i++)V[i]+=1;
    if(X > Y)swap(X,Y);
    X+=1;
    Y+=1;
    //process X;
    long long int now = 0;
    for(int i=X-1;i>=1;i--)
    {
        now += W[i-1];
        a[i] = now;
    }
    now = 0;
    for(int i=X+1;i<=N;i++)
    {
        now += W[i-2];
        a[i] = now;
    }
    now = 0;
    for(int i=Y-1;i>=1;i--)
    {
        now += W[i-1];
        b[i] = now;
    }
    now = 0;
    for(int i=Y+1;i<=N;i++)
    {
        now += W[i-2];
        b[i] = now;
    }
    for(int i=1;i<=N;i++)c[i] = max(a[i],b[i]);
    a[X] = 0;
    b[Y] = 0;
    for(int i=1;i<=N;i++)
    {
        sua[i] = sua[i-1] + a[i];
        sub[i] = sub[i-1] + b[i];
        suc[i] = suc[i-1] + c[i]; // it can't be written as max(sua[i],sub[i]) since it can larger than both of them.
    }
    int maxid = -1;
    for(int i=X;i<=Y-1;i++)
    {
        if(a[i] <= b[i] && a[i+1] >= b[i+1])
        {
            maxid = i;
            break;
        }
    }
    //test maxid:
    long long int all = sua[maxid] - sua[X-1] + sub[Y] - sub[maxid];
    long long int all2 = sua[maxid+1] - sua[X-1] + sub[Y] - sub[maxid+1];
    if(all > all2)maxid+=1;
    priority_queue<long long int> temp;
    long long int s = 0;
    int len2 = 0;
    for(int i=1;i<=N;i++)
    {
        temp.push(0-a[i]);
        temp.push(0-b[i]);
    }
    while(temp.empty() == false)
    {
        long long int xx = temp.top();
        temp.pop();
        s += (0-xx);
        if(s > kk)break;
        else len2++;
    }
    cout<<"len2 "<<len2<<endl;
    cout<<"all "<<all<<endl;
    cout<<"all2 "<<all2<<endl;
    cout<<maxid<<endl;
    if(min(all,all2) <= kk)
    {
        priority_queue<pair<long long int,int> > q;
        for(int i=X-1;i>=1;i--)q.push(make_pair(0-a[i],i));
        for(int i=X;i<=Y;i++)q.push(make_pair(0-abs(b[i] - a[i]),1e9));
        for(int i=Y+1;i<=N;i++)q.push(make_pair(0-b[i],i));
        long long int now = min(all,all2);
        int len = Y-X+1;
        while (now <= kk && q.empty() == false)
        {
            pair<long long int,int> fir = q.top();
            q.pop();
            //cout<<now<<" ";
            if(now + (0-fir.first) <= kk)
            {
                now += (0-fir.first);
                len++;
                if((fir.second < X || fir.second > Y) && fir.second <= N)q.push(make_pair((0-abs(b[fir.second]-a[fir.second])),1e9));
            }
        }
        len2 = max(len,len2);
    }
    return len2;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<U.size();i++)U[i]+=1;
      |                 ~^~~~~~~~~
closing.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<V.size();i++)V[i]+=1;
      |                 ~^~~~~~~~~
# 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 44 ms 18764 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 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 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 -