for _ inrange(n): a, b, c = map(int, input().split()) food.append((b, a, c))
food.sort(reverse=True) q = [] ans = 0 idx = 0
for i inrange(day, 0, -1): while idx < n and food[idx][0] >= i: heapq.heappush(q, (food[idx][1], food[idx][0], food[idx][2])) idx += 1 ifnot q: print(-1) exit() t = heapq.heappop(q) ans += t[0] if t[2] > 1: heapq.heappush(q, (t[0], t[1], t[2] - 1))
#include<bits/stdc++.h> usingnamespace std; constint N = 1e5 + 9; #define x first #define y second int n, m, T; typedef pair<int, int> PII; PII order[N]; bool hot[N]; int last[N], sorce[N]; intmain(){ scanf("%d %d %d", &n, &m, &T); for (int i = 0; i < m; i++) scanf("%d %d", &order[i].x, &order[i].y); sort(order, order + m); for (int i = 0; i < m;) { int j = i; while (j < m && order[j] == order[i]) j++; int id = order[i].y, t = order[i].x, cnt = j - i; i = j; sorce[id] -= t - 1 - last[id]; last[id] = t; if (sorce[id] < 0) sorce[id] = 0; if (sorce[id] <= 3) hot[id] = 0;
sorce[id] += cnt * 2; if (sorce[id] > 5) hot[id] = 1; } for (int i = 1; i <= n; i++) { if (last[i] < T) { sorce[i] -= T - last[i]; if (sorce[i] <= 3) { hot[i] = 0; } } } int ans = 0; for (int i = 1; i <= n; i++) { if (hot[i]) ans++; } printf("%d", ans); return0; }
i = 0 while i < m: j = i while j < m and order[j] == order[i]: j += 1 id = order[i][1] t = order[i][0] cnt = j - i i = j sorce[id] -= t - 1 - last[id] last[id] = t if sorce[id] < 0: sorce[id] = 0 if sorce[id] <= 3: hot[id] = False sorce[id] += cnt * 2 if sorce[id] > 5: hot[id] = True
for i inrange(1, n + 1): if last[i] < T: sorce[i] -= T - last[i] if sorce[i] <= 3: hot[i] = False
#include<bits/stdc++.h> usingnamespace std; vector<int> A, B, C; string a, b;
vector<int> add(vector<int> a, vector<int> b){
vector<int> c; int i = 0, t = 0; while (i < a.size() || i < b.size()) { if (i < a.size())t += a[i]; if (i < b.size())t += b[i]; c.push_back(t % 10); t = t / 10; i++; } if (t == 1) c.push_back(1); return c; }
intmain(){ cin >> a >> b; for (int i = a.size() - 1; i >= 0; --i) A.push_back(a[i] - '0'); for (int i = b.size() - 1; i >= 0; --i) B.push_back(b[i] - '0'); C = add(A, B); for (int i = C.size() - 1; i >= 0; --i) { cout << C[i]; } return0; }
#include<iostream> #define int __int128 // 使用 __int128 需要手写输入输出 usingnamespace std;
constint N = 1e5 + 9;
int n, a[N], x, mp[N], yinzi[N], beishu[N], ans; // mp yinzi beishu 分别记录 x 的出现次数,因子个数,倍数个数
intread(){ int res = 0, p = 1; char c; c = getchar(); // 非数字 while (c < '0' || c > '9') { if (c == '-')p = -1; c = getchar(); } // 数字 while (c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar(); } return p * res; }
#include<bits/stdc++.h> usingnamespace std; int n, k; constint N = 1e5 + 9; typedef pair<int, int> PII; #define x first #define y second PII ckl[N]; boolcheck(int h){ int ans = 0; for (int i = 0; i < n; i++) { ans += (ckl[i].x / h) * (ckl[i].y / h); if (ans >= k) returntrue; //符合 } returnfalse; } intmain(){ ios::sync_with_stdio(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> ckl[i].x >> ckl[i].y; } int l = 1, r = N; while (l < r) { int mid = l + r + 1 >> 1; if (check(mid)) l = mid; else r = mid - 1; } cout << l << endl; return0; }