```
class MedianFinder {
public:
vector<int> nums;
double n1,n2;
// Adds a number into the data structure.
void addNum(int num) {
nums.push_back(num);
int size = nums.size();
vector<int>::iterator m1 = nums.begin() + (size - 1) / 2;
vector<int>::iterator m2 = nums.begin() + (size - 1) / 2 + 1;
if (size % 2 == 0){
nth_element(nums.begin(), m1, nums.end());
nth_element(nums.begin(), m2, nums.end());
n1 = (double)nums[(size - 1) / 2];
n2 = (double)nums[(size - 1) / 2 + 1];
}else{
nth_element(nums.begin(), m1, nums.end());
n1 = (double)nums[(size - 1) / 2];
n2 = n1;
}
}
// Returns the median of current data stream
double findMedian() {
return (n1 + n2) / 2.0;
}
};
```

I think my logic is right. However, this code is WA. Could you tell me where the error is ?