Submission #78356

# Submission time Handle Problem Language Result Execution time Memory
78356 2018-10-04T05:26:39 Z SamAnd Job Scheduling (CEOI12_jobs) C++17
20 / 100
298 ms 33792 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N=1000006;
struct ban
{
    int x,i;
};
bool operator<(const ban& a,const ban& b)
{
    if(a.x<b.x)
        return true;
    if(a.x>b.x)
        return false;
    return a.i<b.i;
}

int n,d,m;
ban a[N];

vector<int> v[N];
bool stgg(int x)
{
    int o=1,xx=0;
    for(int i=0;i<m;++i)
    {
        while(a[i].x>o)
        {
            ++o;
            xx=0;
        }
        if(o>n)
            return false;
        ++xx;
        v[o].push_back(a[i].i);
        if(xx==x)
        {
            ++o;
            xx=0;
        }
    }
    return true;
}

bool stg(int x)
{
    int o=1,xx=0;
    for(int i=0;i<m;++i)
    {
        while(a[i].x>o)
        {
            ++o;
            xx=0;
        }
        if(o>n)
            return false;
        ++xx;
        if(xx==x)
        {
            ++o;
            xx=0;
        }
    }
    return true;
}

int byn()
{
    int l=1,r=m;
    while((r-l)>3)
    {
        int mid=(l+r)/2;
        if(stg(mid))
            r=mid;
        else
            l=mid;
    }
    for(int mid=l;mid<=r;++mid)
        if(stg(mid))
            return mid;
}

int main()
{
    //freopen("input.txt","r",stdin);
    scanf("%d%d%d",&n,&d,&m);
    for(int i=0;i<m;++i)
    {
        scanf("%d",&a[i].x);
        a[i].i=i+1;
    }
    sort(a,a+m);
    int ans=byn();
    stgg(ans);
    cout<<ans<<endl;
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<v[i].size();++j)
            cout<<v[i][j]<<' ';
        cout<<0<<endl;
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:98:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v[i].size();++j)
                     ~^~~~~~~~~~~~
jobs.cpp: In function 'int byn()':
jobs.cpp:81:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
jobs.cpp: In function 'int main()':
jobs.cpp:86:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&d,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:89:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i].x);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 25976 KB Output isn't correct
2 Incorrect 67 ms 26196 KB Output isn't correct
3 Incorrect 67 ms 26196 KB Output isn't correct
4 Incorrect 69 ms 26224 KB Output isn't correct
5 Incorrect 70 ms 26224 KB Output isn't correct
6 Incorrect 68 ms 26224 KB Output isn't correct
7 Incorrect 67 ms 26224 KB Output isn't correct
8 Incorrect 70 ms 26224 KB Output isn't correct
9 Incorrect 238 ms 28780 KB Output isn't correct
10 Incorrect 246 ms 28780 KB Output isn't correct
11 Correct 71 ms 28780 KB Output is correct
12 Correct 97 ms 28780 KB Output is correct
13 Correct 141 ms 30496 KB Output is correct
14 Correct 214 ms 32592 KB Output is correct
15 Runtime error 216 ms 33360 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
16 Runtime error 298 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
17 Runtime error 291 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 260 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 292 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 249 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)