답안 #78357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78357 2018-10-04T05:29:42 Z SamAnd Job Scheduling (CEOI12_jobs) C++17
10 / 100
283 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;
        if(a[i].x+d<=o)
            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:100: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:83:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
jobs.cpp: In function 'int main()':
jobs.cpp:88: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:91:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i].x);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 25840 KB Output isn't correct
2 Incorrect 65 ms 26048 KB Output isn't correct
3 Incorrect 70 ms 26048 KB Output isn't correct
4 Incorrect 66 ms 26048 KB Output isn't correct
5 Incorrect 67 ms 26048 KB Output isn't correct
6 Incorrect 65 ms 26056 KB Output isn't correct
7 Incorrect 65 ms 26072 KB Output isn't correct
8 Incorrect 67 ms 26072 KB Output isn't correct
9 Incorrect 214 ms 26256 KB Output isn't correct
10 Incorrect 220 ms 26256 KB Output isn't correct
11 Correct 63 ms 26256 KB Output is correct
12 Incorrect 100 ms 28028 KB Output isn't correct
13 Correct 155 ms 30500 KB Output is correct
14 Incorrect 202 ms 32536 KB Output isn't correct
15 Runtime error 215 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.
16 Runtime error 279 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 238 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 253 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 283 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)