結果
問題 | No.1679 マスゲーム |
ユーザー | pengin_2000 |
提出日時 | 2022-10-13 22:44:04 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,611 bytes |
コンパイル時間 | 916 ms |
コンパイル使用メモリ | 29,564 KB |
実行使用メモリ | 9,732 KB |
最終ジャッジ日時 | 2023-09-08 19:16:35 |
合計ジャッジ時間 | 5,179 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,972 KB |
testcase_01 | AC | 2 ms
7,872 KB |
testcase_02 | AC | 2 ms
7,984 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
7,976 KB |
testcase_18 | AC | 67 ms
9,732 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 2 ms
7,916 KB |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
7,980 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
ソースコード
#include<stdio.h> long long int h[200005], l; int comp_h(long long int a, long long int b) { if (h[a] > h[b]) return 1; else return -1; } void swap_h(long long int a, long long int b) { long long int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(long long int ne) { h[l] = ne; long long int p = l; l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } long long int pop() { l--; swap_h(0, l); long long int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } long long int a[200005], b[200005], t[200005]; long long int x[200005], y[200005], xx, yy; int main() { long long int n; scanf("%lld", &n); long long int i; for (i = 0; i < n; i++) scanf("%lld %lld %lld", &a[i], &b[i], &t[i]); l = 0; for (i = 0; i < n; i++) if (a[i] == 0) push(t[i] + b[i]); for (xx = 0; l > 0; xx++) x[xx] = pop(); l = 0; for (i = 0; i < n; i++) if (a[i] == 1) push(t[i] + b[i]); for (yy = 0; l > 0; yy++) y[yy] = pop(); long long int ans = 0, left, right; y[yy] = 1e18; for (left = right = 0, i = 0; i < xx; i++) { while (y[left] < x[i]) left++; while (y[right] <= x[i]) right++; ans += right - left; } printf("%lld\n", ans); return 0; }