#include <iostream> #include <string> using namespace std; class Stack { private: int Top; public: Stack(int n); void Push(); void Pop(); int GetSize(); }; Stack::Stack(int n) { Top = 0; } void Stack::Push() { Top++; } void Stack::Pop() { Top--; } int Stack::GetSize() { return Top; } int main() { int TestCase; cin >> TestCase; while (TestCase) { TestCase--; Stack S(0); string sInput; cin >> sInput; for (int i = 0; i < sInput.size(); i++) { if (sInput[i] == '(') S.Push(); else if (sInput[i] == ')') S.Pop(); else break; if(S.GetSize() == -1) break; } if (S.GetSize() == 0) cout << "YES" << endl; else cout << "NO" << endl; } }
# include < iostream > # include < cstdio > # include < algorithm > int main ( ) { int * Number = new int [ 5000000 ] ; int N , K ; scanf ( " %d %d " , & N , & K ) ; for ( int i = 0 ; i < N ; i + + ) scanf ( " %d " , Number [ i ] ) ; std :: sort ( Number , Number + N ) ; printf ( " %d " , Number [ K - 1 ] ) ; return 0 ; }
댓글
댓글 쓰기