답안 #528850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528850 2022-02-21T15:20:40 Z aSSSd 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
c#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
    return l+rng()%(r-l+1);
}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define forinc(x,a,b) for(int x=a;x<=b;x++)
#define fordec(x,a,b) for(int x=a;x>=b;x--)
#define iii pair<ii,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define mt make_tuple
#define getbit(x,i) ((x>>(i))&1)
#define batbit(x,i) (x|(1ll<<(i)))
#define tatbit(x,i) (x&~(1<<(i)))
#define endl '\n'
#define all(v) v.begin(), v.end()
#define gg exit(0);
#define int long long
const int N = 1e5 + 100;
int n;
int a[N];
long long b;
int len;
int xuoi[N], ngc[N];
int f[N], g[N];
bool check(int mid)
{
    long long cur = b;
    int ret =0;
    forinc(i,1,n)
    {
        if(i + mid - 1 > n) break;
        int med = (i+i+mid)/2;
        int lenn = mid/2;
        if(mid&1)
        {
            int trc=xuoi[med+lenn-1]-f[med-1]*lenn- xuoi[med-1];
            int sau=ngc[med-lenn+1]-g[med+1]*lenn- ngc[med+1];
            if  (trc + sau <= cur) return 1;
        }
        else
        {
            int trc = xuoi[med + lenn - 2] - f[med-1]*(lenn-1) - xuoi[med-1];
            int sau = ngc[med-lenn+1] - g[med+1]*lenn - ngc[med+1];
            if(trc + sau <= cur) return 1;
        }
    }
    return 0;
}
main()
{
    fasty;

    // freopen("dbz.inp", "r", stdin);
     //freopen("dbz.out", "w", stdout);
    cin >> n >> len >> b;
    forinc(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    forinc(i,1,n-1)
    {
        f[i] = f[i-1] + a[i+1] - a[i];
        xuoi[i] = xuoi[i-1] + f[i];
    }
    fordec(i,n,2)
    {
        g[i] = g[i+1] + a[i] - a[i-1];
        ngc[i] = ngc[i+1] + g[i];
    }
    int l=1;
    int res;
    int r = n;
    while(l <= r)
    {
        int mid = (l+r)/2;
        if(check(mid))
        {
            res = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    cout << res;
}


Compilation message

ricehub.cpp:1:2: error: stray '#' in program
    1 | c#include <bits/stdc++.h>
      |  ^
ricehub.cpp:1:1: error: 'c' does not name a type
    1 | c#include <bits/stdc++.h>
      | ^
ricehub.cpp:3:1: error: 'mt19937' does not name a type
    3 | mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      | ^~~~~~~
ricehub.cpp: In function 'int rnd(int, int)':
ricehub.cpp:6:14: error: 'rng' was not declared in this scope; did you mean 'rnd'?
    6 |     return l+rng()%(r-l+1);
      |              ^~~
      |              rnd
ricehub.cpp: In function 'bool check(long long int)':
ricehub.cpp:35:9: warning: unused variable 'ret' [-Wunused-variable]
   35 |     int ret =0;
      |         ^~~
ricehub.cpp: At global scope:
ricehub.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main()
      | ^~~~
ricehub.cpp: In function 'int main()':
ricehub.cpp:8:15: error: 'ios_base' has not been declared
    8 | #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |               ^~~~~~~~
ricehub.cpp:58:5: note: in expansion of macro 'fasty'
   58 |     fasty;
      |     ^~~~~
ricehub.cpp:8:44: error: 'cin' was not declared in this scope
    8 | #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |                                            ^~~
ricehub.cpp:58:5: note: in expansion of macro 'fasty'
   58 |     fasty;
      |     ^~~~~
ricehub.cpp:8:55: error: 'cout' was not declared in this scope
    8 | #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |                                                       ^~~~
ricehub.cpp:58:5: note: in expansion of macro 'fasty'
   58 |     fasty;
      |     ^~~~~
ricehub.cpp:64:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   64 |     sort(a+1, a+n+1);
      |     ^~~~
      |     short