結果
問題 |
No.3116 More and more teleporter
|
ユーザー |
![]() |
提出日時 | 2025-04-19 00:59:16 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 1,140 ms |
コンパイル使用メモリ | 25,856 KB |
実行使用メモリ | 12,548 KB |
最終ジャッジ日時 | 2025-04-19 00:59:19 |
合計ジャッジ時間 | 2,082 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:40:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%lld %lld", &n, &q); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ main.c:50:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%lld", &t); | ^~~~~~~~~~~~~~~~~ main.c:53:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf("%lld", &x); | ^~~~~~~~~~~~~~~~~ main.c:59:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%lld %lld", &x, &c); | ^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } long long int seg[2][800005], ss; void update(long long int z, long long int x, long long int v) { x += ss - 1; seg[z][x] = min(seg[z][x], v); while (x > 0) { x = (x - 1) / 2; seg[z][x] = min(seg[z][2 * x + 1], seg[z][2 * x + 2]); } return; } long long int get_min(long long int z, long long int l, long long int r) { l += ss - 1; r += ss - 1; long long int res = 1e18; while (l < r) { res = min(res, seg[z][l]); l /= 2; res = min(res, seg[z][r]); r = r / 2 - 1; } if (l == r) res = min(res, seg[z][l]); return res; } int main() { long long int n, q; scanf("%lld %lld", &n, &q); long long int i; for (ss = 1; ss < n; ss *= 2); for (i = 0; i < 2 * ss - 1; i++) seg[0][i] = seg[1][i] = 1e18; update(0, 0, 0); update(1, 0, 0); long long int t, x, c; for (i = 0; i < q; i++) { scanf("%lld", &t); if (t == 1) { scanf("%lld", &x); x--; printf("%lld\n", min(get_min(0, 0, x) + x, get_min(1, x, n - 1) - x)); } else { scanf("%lld %lld", &x, &c); x--; update(0, x, c - x); update(1, x, c + x); } } return 0; }