现在的位置: 首页 > 综合 > 正文

Codeforces Round #280 (Div. 2)

2018年01月22日 ⁄ 综合 ⁄ 共 1910字 ⁄ 字号 评论关闭

30min的时候提醒电量剩余10%,35min的时候水过B题,关电脑睡觉

updata1:早上6:45开始补题,15min写完C,调到8:12,怎么搞的,思路很清楚,写起来超乱。写完了CF也挂了...

两点原因:重载'<'写反了,排序按从大到小排的,每个变量不清楚什么意义,一步一步写闲长,写短了思维跟不上?

updata2:现在是9:17,AC了C,k的位置放错少了一次循环导致TLE,一道简单题改了2个多小时,吸取教训了

p.s.房间里大部分人WA在13,有个long long的地方没注意到

A - Vanya and Cubes

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
LL A[70];
LL S[70];
int main() {
    for (int i = 1; i <= 40; i++) {
        A[i] = A[i-1] + i;
    }
    for (int i = 1; i <= 40; i++) {
        S[i] += S[i-1] + A[i];
    }
    int n;
    scanf("%d", &n);
    int k = upper_bound(S, S+40, n) - S;
    printf("%d\n", k-1);
    return 0;
}

B - Vanya and Lanterns

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
int A[1111];
int main() {
    int n, l;
    scanf("%d%d", &n, &l);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    sort(A, A+n);
    int minn = -1;
    for (int i = 1; i < n; i++) {
        minn = max(minn, A[i]-A[i-1]);
    }
    int minn1 = -1, minn2 = -1;
    if (A[0] != 0) minn1 = max(minn1, A[0]);
    if (A[n-1] != l) minn2 = max(minn2, l-A[n-1]);
    minn1 = max(minn1, minn2);
    double ans;
    if (2*minn1 > minn) ans = (double)minn1*1.0;
    else ans = minn*1.0/2;
    printf("%.9f\n", ans);
    return 0;
}

C - Vanya and Exams

#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
struct point {
    int a, b, c;
    bool operator <(const point &A) const {
        return b < A.b;
    }
}p[100001];

int main() {
    LL ans = 0, cnt = 0, avg, n, r;
    scanf("%lld%lld%lld", &n, &r, &avg);
    for (int i = 0; i < n; i++) {
       scanf("%lld%lld", &p[i].a , &p[i].b);
       ans += p[i].a;
    }
    avg *= n;
    sort(p, p + n);
    LL i = 0;
    int k = 0;
    for (i = 0; i < avg-ans; i += (r-p[k].a),k++) {
        cnt += (r - p[k].a)*p[k].b;
    }
    while (i > avg-ans) {
        cnt -= p[k-1].b;
        i--;
    }
    printf("%lld\n", cnt < 0 ? 0 : cnt);
    return 0;
}          

D. Vanya and Computer Game

没读懂题意系列:两个人打怪,一个每秒x下,另一个每秒y下,一个怪最多承受a下攻击,问谁给出了最后一击

只考虑他们两个人的相对速度,则甲每y秒打一下,乙每x秒打一下,然后二分时间t

#include <cstdio>
typedef long long LL;

int main() {
    LL n, x, y, a;
    scanf("%lld%lld%lld", &n, &x, &y);
    while (n--) {
        scanf("%lld", &a);
        LL l = 0, r = 1LL<<60, mid;
        while(l <= r) {
            mid = (l+r)>>1;
            if (mid/x + mid/y >= a) r = mid - 1;
            else l = mid + 1;
        }
        mid = r + 1;
        if(mid%x==0&&mid%y==0) puts("Both");
        else if(mid%y==0) puts("Vanya");
        else puts("Vova");
    }
    return 0;
}





抱歉!评论已关闭.