------
## 最终结论
```python
def longest_well_performing_interval(hours):
    score = 0
    score_map = {0: -1}
    max_length = 0

    for i, h in enumerate(hours):
        if h > 8:
            score += 1
        else:
            score -= 1

        if score > 0:
            max_length = i + 1
        elif score - 1 in score_map:
            max_length = max(max_length, i - score_map[score - 1])

        if score not in score_map:
            score_map[score] = i

    return max_length

# Example usage:
hours = [9,9,6,0,6,6,9]
print(longest_well_performing_interval(hours))  # Output: 3
```