Submission #803650

# Submission time Handle Problem Language Result Execution time Memory
803650 2023-08-03T05:16:24 Z vjudge1 Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 21372 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 3e5 ;
ll n, m, l = 0, r = 1e18, a[N + 1], b[N + 1] ;
set<pair<ll, ll>> s, s1, s2, s3 ;
signed main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    cin >> n >> m ;
    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])
            s.insert({m, i}) ;
        else
            s2.insert({m, i}) ;
    }
    while(l + 1 < r)
    {
        s1 = s ;
        s3 = s2 ;
        ll mid = (l + r) >> 1 ;
        bool cnt = 0 ;
        for(int i = 1 ; i <= n ; i++)
            if(a[i] > b[i])
            {
            }
            else
            {
                ll num = (mid + b[i] - 1) / b[i] ;
                while(s1.size() && num)
                {
                    pair<ll, ll> p = (*s1.rbegin()) ;
                    s1.erase(p) ;
                    ll abu = min(num, p.fi) ;
                    num -= abu ;
                    p.fi -= abu ;
                    if(p.fi)
                        s1.insert({p.fi, p.se}) ;
                }
                if(num)
                {
                    if(!s3.size())
                    {
                        cnt = 1 ;
                        break ;
                    }
                }
            }
        if(cnt)
            r = mid ;
        else
            l = mid ;
    }
    cout << l ;
    return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Execution timed out 1080 ms 21372 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Execution timed out 1080 ms 21372 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -