Submission #636680

# Submission time Handle Problem Language Result Execution time Memory
636680 2022-08-29T22:34:28 Z danikoynov Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 212 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll maxn = 300010;
ll n, m;
ll a[maxn], b[maxn], in[maxn], out[maxn], cp[maxn];

bool check(ll mf)
{
 ll nec = 0, op = n * m;
            for (int i = 1; i <= n; i ++)
            {
                if (a[i] >= b[i])
                {
                    ll loc = mf / a[i];
                    if (mf % a[i] != 0)
                        loc ++;
                    ll to_use = min(m, loc);
                    op = op - to_use;

                    nec = nec + max((ll)0, (mf - to_use * a[i])) / b[i];
                    if ( max((ll)0, (mf - to_use * a[i])) % b[i] != 0)
                        nec ++;


                }
                else
                {
                nec = nec + mf / b[i];
                if (mf % b[i] != 0)
                    nec ++;
                }
                ///cout << i << " " << nec << endl;
            }
        return nec <= op;
}
void solve()
{
    cin >> n >> m;
    bool diff = false;
    for (ll i = 1; i <= n; i ++)
        cin >> a[i];
    for (ll i = 1; i <= n; i ++)
    {
        cin >> b[i];
        if (b[i] != a[i])
            diff = true;
    }
    ll m1 = 1e18;
    for (int i = 1; i <= n; i ++)
        m1=  min(m1, max(a[i], b[i]));

        double sum = 0;
        for (int i = 1; i <= n; i ++)
            sum = sum + (double)m / (double)(n) * (double)a[i];


        ll lf = 0, rf = ceil(sum);
        while(lf <= rf)
        {
            ll mf = (lf + rf) / 2;

            if (check(mf))
                lf = mf + 1;
            else
                rf = mf - 1;
        }
        if (rf > m1)
            while(true);
        cout << rf << endl;

}

int main()
{
    solve();
    return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:68:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |     for (int i = 1; i <= n; i ++)
      |     ^~~
Main.cpp:71:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   71 |         double sum = 0;
      |         ^~~~~~
Main.cpp:58:10: warning: variable 'diff' set but not used [-Wunused-but-set-variable]
   58 |     bool diff = false;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -