답안 #1020385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020385 2024-07-12T03:12:18 Z cpptowin Self Study (JOI22_ho_t2) C++17
0 / 100
135 ms 5260 KB
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i = l; i <= r; i++)
#define fod(i,r,l) for(int i = r ; i >= l; i--)
#define int long long
#define maxn 1000010
#define N 1010
#define inf (int)1e18
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define en cout << "\n";
#define ss(x) (int)x.size()
#define bitcount(x) __builtint_popcountll(x)
#define bit(x,i) ((x >> i) & 1)
#define onbit(x,i) (x | (1ll << i))
#define offbit(x,i) (x ^ (1ll << i))
#define lb(x) x & -x
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define fi first
#define se second
bool maximize(int &a,int b)
{
    if(a <= b)
    {
        a = b;
        return 1;
    }
    return 0;
}
bool minimize(int &a,int b)
{
    if(a >= b)
    {
        a = b;
        return 1;
    }
    return 0;
}
using namespace std;
int n,m;
int a[maxn],b[maxn];
namespace sub3
{
    bool check(int x)
    {
        int r = 0;
        fo(i,1,n)
        {
            int val = x / a[i] + (x % a[i] > 0);
            if(val <= m) r += m - val;
            else
            {
                int cc = x - m * a[i];
                cc = cc / b[i] + (cc % b[i] > 0);
                r -= cc;
            }
        }
        return r >= 0;
    }
    void solve()
    {
        fo(i,1,n) a[i] = max(a[i],b[i]);
        int l = 0,r = inf,ans = 0;
        while(l <= r)
        {
            int mid = l + r >> 1;
            if(check(mid)) ans = mid,l = mid + 1;
            else r = mid - 1;
        }
        cout << ans;
    }
}
main()
{
    #define name "bai1"
    if(fopen(name".inp","r"))
    {
        freopen(name".inp","r",stdin);
        freopen(name".out","w",stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    fo(i,1,n) cin >> a[i];
    fo(i,1,n) cin >> b[i];
    sub3::solve();
}

Compilation message

Main.cpp: In function 'void sub3::solve()':
Main.cpp:67:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   67 |             int mid = l + r >> 1;
      |                       ~~^~~
Main.cpp: At global scope:
Main.cpp:74:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   74 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen(name".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(name".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 111 ms 5260 KB Output is correct
12 Correct 109 ms 5040 KB Output is correct
13 Correct 107 ms 5096 KB Output is correct
14 Incorrect 135 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 60 ms 2688 KB Output is correct
10 Correct 39 ms 1884 KB Output is correct
11 Correct 34 ms 1624 KB Output is correct
12 Correct 25 ms 1372 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Incorrect 3 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 111 ms 5260 KB Output is correct
12 Correct 109 ms 5040 KB Output is correct
13 Correct 107 ms 5096 KB Output is correct
14 Incorrect 135 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 60 ms 2688 KB Output is correct
10 Correct 39 ms 1884 KB Output is correct
11 Correct 34 ms 1624 KB Output is correct
12 Correct 25 ms 1372 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Incorrect 3 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 111 ms 5260 KB Output is correct
12 Correct 109 ms 5040 KB Output is correct
13 Correct 107 ms 5096 KB Output is correct
14 Incorrect 135 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -