제출 #718559

#제출 시각아이디문제언어결과실행 시간메모리
718559vinnipuh01Self Study (JOI22_ho_t2)C++17
0 / 100
475 ms10876 KiB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
#define sqrt sqrtl

using namespace std;

const long long oo = 1000000000000000000;

long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;


    freopen ( "sum.in", "r", stdin )
*/

int n, m, a[ 300001 ], b[ 300001 ];

bool ok( int x ) {
	sum = 0;
	for ( int i = 1; i <= n; i ++ ) {
		num = x / a[ i ];
		if ( x % a[ i ] ) {
			num ++;
		}
		if ( num <= m )
			sum += m - num;
		else {
			pos = ( num - m - 1 ) * a[ i ];
			if ( x % a[ i ] )
				pos += x % a[ i ];
			else
				pos += a[ i ];
			pos = pos / b[ i ] + (bool)( pos % b[ i ] );
			sum -= pos;
		}
	}
	return sum >= 0;
}

main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> m;
    for ( int i = 1; i <= n; i ++ )
    	cin >> a[ i ];
    for ( int i = 1; i <= n; i ++ ) {
    	cin >> b[ i ];
    	if ( b[ i ] > a[ i ] )
    		a[ i ] = b[ i ];
    }
    int l, r, mid;
    l = 1;
    r = oo;
    while ( r - l > 1 ) {
    	mid = ( l + r ) / 2;
    	if ( ok( mid ) )
    		l = mid;
    	else
    		r = mid - 1;
	}
	if ( ok( r ) )
		l = r;
	cout << l;
}

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

Main.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main () {
      | ^~~~
#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...