답안 #26287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26287 2017-06-29T05:06:54 Z 까제비(#1110) Zagrade (COI17_zagrade) C++
0 / 100
3 ms 3484 KB
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e5 + 100;

int N, Lv[MAX_N]; char S[MAX_N];
int main() {
	cin >> N; scanf("%s", S);

	int lv = 0;
	ll ans = 0;
	for(int i=0; i<N; i++) {
		if(S[i] == '(') {
			Lv[lv]++;
			lv++;
		} else {
			Lv[lv] = 0;
			lv--;
			ans += Lv[lv];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:20:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  cin >> N; scanf("%s", S);
                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3484 KB Output isn't correct
2 Halted 0 ms 0 KB -