結果
問題 | No.3144 Parentheses Modification and Rotation (01 Ver.) |
ユーザー |
![]() |
提出日時 | 2025-05-16 22:31:35 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 425 ms |
コンパイル使用メモリ | 27,084 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-16 22:31:37 |
合計ジャッジ時間 | 1,579 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%s", s); | ^~~~~~~~~~~~~~ main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d %d", &r, &m); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> char s[100005]; int main() { int n; scanf("%d", &n); scanf("%s", s); int r, m; scanf("%d %d", &r, &m); if (n % 2 > 0) { printf("-1\n"); return 0; } int i, cnt[2] = { 0,0 }; for (i = 0; i < n; i++) { if (s[i] == '(') cnt[0]++; else cnt[1]++; } int ans = cnt[0] - cnt[1]; if (ans < 0) ans *= -1; ans /= 2; printf("%d\n", ans); return 0; }