AtCoder Contest 144 D\E

https://atcoder.jp/contests/abc144/tasks/abc144_d

 

(感谢 revollA 同学的解答)

Problem D have two conditions
1、 water is so much x*2 >= a*a*b

2、 water is so little x*2 < a*a*b

 

 

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double PI = 3.141592653589793238462643383279;// const double PI = acos(-1);

int main(){
    int a,b,x;
    scanf("%d%d%d", &a, &b, &x);
    double o;
    if(x*2 <= a*a*b) {
        o = atan2(b*b*a, 2*x);
    }else {
        o = atan2(2*(a*a*b-x), a*a*a);
    }
    printf("%.10lf\n", o/PI*180);
    return 0;
}

 

 https://atcoder.jp/contests/abc144/tasks/abc144_e

//首先消費指數 和 食物的困難程度的乘積為 分數
//假設 最小可能得分數為 x, 
//要使x 盡可能小 便要 消費指數 大的和 困難程度小的
//所以可以排個序, 一個升序 一個降序
//二分查找 x , 如果得分 x 需要做出的改變為 m (m <= k時x才有效)
// Ai Fi <= 1e6, so  x <= 1e12 
//每個 Ai'Fi == x,  需要做的改變為 max(Ai-m, 0)  m = x/Fi
// O(logx*n)
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
const int N = 2e5+100;
int a[N], f[N],n;
int main(){     
    ll k; cin >> n >> k; 
    _for(i,0,n) cin >> a[i];
    _for(i,0,n) cin >> f[i];
    sort(a,a+n); sort(f,f+n, greater<int>());
    ll l = 0 , r = 1e12;
    while(l < r) {
        ll sum = 0; ll x = (l+r) >> 1;
        _for(i,0,n) sum += max(0ll, a[i]-x/f[i]);
        if(sum <= k) r = x;
        else l = x+1;
    }
    cout << l << endl;  
    return 0;
}

 

posted @ 2019-10-28 16:14  163467  阅读(...)  评论(... 编辑 收藏