제출 #824365

#제출 시각아이디문제언어결과실행 시간메모리
824365AmylopectinSelf Study (JOI22_ho_t2)C++14
100 / 100
215 ms10772 KiB
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const long long mxn = 1e6 + 10,mxi = 2e18 + 10;
long long a[mxn] = {},b[mxn] = {}; 
int main()
{
    long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
    scanf("%lld %lld",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        scanf("%lld",&b[i]);
    }
    cl = 1;
    cr = mxi;
    while(cl < cr)
    {
        mid = (cl+cr) / 2 + (cl+cr) % 2;
        csu = 0;
        for(i=0; i<n; i++)
        {
            if(a[i] > b[i])
            {
                if(m * a[i] >= mid)
                {
                    csu += (mid-1) / (a[i]) + 1;
                }
                else 
                {
                    csu += m + ((mid - 1 - m*a[i]) / b[i]) + 1;
                }
            }
            else 
            {
                csu += (mid-1) / (b[i]) + 1;
            }
            if(csu > n*m)
            {
                break;
            }
        }
        if(csu > n*m)
        {
            cr = mid-1;
        }
        else 
        {
            cl = mid;
        }
    }
    printf("%lld\n",cl);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:9:17: warning: unused variable 'j' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                 ^
Main.cpp:9:23: warning: unused variable 'cn' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                       ^~
Main.cpp:9:26: warning: unused variable 'cm' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                          ^~
Main.cpp:9:29: warning: unused variable 'fn' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                             ^~
Main.cpp:9:32: warning: unused variable 'fm' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                                ^~
Main.cpp:9:45: warning: unused variable 'cva' [-Wunused-variable]
    9 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,mid,cva,csu;
      |                                             ^~~
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld %lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld",&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...