TLE, 30pts
查看原帖
TLE, 30pts
384214
esquigybcu楼主2020/11/1 10:26
#include <stdio.h>
#define SIZE 100000

int main()
{
    int n, type[SIZE], price[SIZE], t[SIZE], ans = 0, flag;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d", type+i, price+i, t+i);
        if (type[i] == 0)
            ans += price[i];
        else
        {
            flag = 0;
            for (int j = 0; j < i; j++)
                if (type[j] == 0 && t[i] - t[j] <= 45 && price[i] <= price[j])
                {
                    flag = 1;
                    price[j] = -1; // mark as used
                    break;
                }
            if (flag == 0)
                ans += price[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}
2020/11/1 10:26
加载中...