Finding max depth of nested parentheses
Soooooooo many iterations

You can check if the nested braces are valid in a single run through the string. Your code currently does 6n+1 iterations (!!) - and I have no idea what n is there for. You have a loop which does not reference i at all, so at the very least you could just do that part once (which would drop you to just 7 iterations), but really you should do the loop zero times. That's why it's slow. Soooo much unnecessary work!

Wrong output

If maxDepth returns -1, you will print -1 instead of "NIE". 

A better algorithm

This is a problem that calls for a stack. When you get an open brace, you add it to the stack (updating maximum size as necessary). When you get a close brace, you check the top value of the stack - if it matches, you're good and you pop. If it doesn't match or the stack is empty - it's invalid and you return -1. If at the end of the string the stack isn't empty, it's invalid and you return -1 too. 

That's one single pass. It will also handle the case I mentioned in comments of ({)} which your code would incorrectly return 2.

Code specifics


Avoid using namespace std;
Prefer C++11's range based for loops. In maxDepth(), iterate for (char c : S). 
When you're comparing against multiple things like you do, when you're not actually differentiating between the different values, it's clearer to just use a switch statement:

for (char c : S) {
    switch (c) {
    case '(':
    case '{':
    case '[': 
       ...
       break;
    case ')':
    case '}':
    case ']': 
       ...
       break;
    }
}

In maxDepth(), you don't alter the string, so you should take it by reference to const. 
Declare variables when you need them. In main(), you loop over i so declare i in the for-loop itself, not up front. This isn't C.