Submission #1062912

# Submission time Handle Problem Language Result Execution time Memory
1062912 2024-08-17T11:50:26 Z TlenekWodoru Carnival Tickets (IOI20_tickets) C++14
25 / 100
700 ms 141120 KB
#include<bits/stdc++.h>
#include "tickets.h"
using namespace std;
struct Node
{
    int x;
    int i,j;
    bool operator <(const Node &B)const
    {
        if(x==B.x)
        {
            if(i==B.i){return j<B.j;}
            else{return i<B.i;}
        }
        else{return x<B.x;}
    }
};
int k,n,m,n2;
vector<vector<int>>answer;
vector<vector<Node>>Tab;
vector<Node>Lista;
vector<int>V1[1509],V2[1509];
int CzyZajal[1509];
bool CzyMozna(Node x)
{
    int s1=0,s2=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(Tab[i][j]<x){s1++;}
            else{s2++;}
        }
    }
    return s1>=s2;
}
Node BinSearch()
{
    int l=0;
    int p=(int)Lista.size()-1;
    while(l<p)
    {
        const int mid=(l+p)>>1;
        if(CzyMozna(Lista[mid])){p=mid;}
        else{l=mid+1;}
    }
    return Lista[l];
}
long long find_maximum(int K, vector<vector<int>>A)
{
    k=K;
    n = A.size();
    n2=n/2;
    m = A[0].size();
    answer.resize(n,vector<int>(m,-1));
    for(int i=0;i<n;i++)
    {
        vector<Node>Temp;
        for(int j=0;j<m;j++)
        {
            Temp.push_back({A[i][j],i,j});
            Lista.push_back({A[i][j],i,j});
        }
        sort(Temp.begin(),Temp.end());
        Tab.push_back(Temp);
    }
    sort(Lista.begin(),Lista.end());
    Node xd=Lista[(int)Lista.size()/2];
    long long wynik=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(Tab[i][j]<xd)
            {
                wynik-=Tab[i][j].x;
                V1[i].push_back(Tab[i][j].j);
            }
            else
            {
                wynik+=Tab[i][j].x;
                V2[i].push_back(Tab[i][j].j);
            }
        }
    }
    memset(CzyZajal,-1,sizeof(CzyZajal));
    for(int i=0;i<k;i++)
    {
        int ile=0;
        for(int j=0;j<n;j++)
        {
            if(ile==n2){break;}
            if((int)V1[j].size()>0&&(int)V2[j].size()==0)
            {
                int u=V1[j].back();
                V1[j].pop_back();
                CzyZajal[j]=i;
                answer[j][u]=i;
                ile++;
            }
        }
        for(int j=0;j<n;j++)
        {
            if(ile==n2){break;}
            if((int)V1[j].size()>0&&CzyZajal[j]!=i)
            {
                int u=V1[j].back();
                V1[j].pop_back();
                CzyZajal[j]=i;
                answer[j][u]=i;
                ile++;
            }
        }
        for(int j=0;j<n;j++)
        {
            if(CzyZajal[j]!=i&&(int)V2[j].size()>0)
            {
                int u=V2[j].back();
                V2[j].pop_back();
                answer[j][u]=i;
            }
        }
    }
    allocate_tickets(answer);
    return wynik;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 803235448 but the tickets gives a total value of 1095508474
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Contestant returned 4 but the tickets gives a total value of 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 24 ms 6188 KB Output is correct
6 Correct 4 ms 1368 KB Output is correct
7 Correct 5 ms 1624 KB Output is correct
8 Correct 615 ms 140952 KB Output is correct
9 Correct 653 ms 132576 KB Output is correct
10 Correct 654 ms 131728 KB Output is correct
11 Correct 700 ms 141120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 2 ms 856 KB Contestant returned 19938459097 but the tickets gives a total value of 1593618503176
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 2 ms 856 KB Contestant returned 19938459097 but the tickets gives a total value of 1593618503176
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Incorrect 0 ms 348 KB Contestant returned 803235448 but the tickets gives a total value of 1095508474
8 Halted 0 ms 0 KB -