It has long been known, since the classical work of (Arora, Karger, Karpinski, JCSS 99), that Max-CUT admits a PTAS on dense graphs, and more generally, Max-k-CSP admits a PTAS on "dense" instances with Ω(n k ) constraints. In this paper we extend and generalize their exhaustive sampling approach, presenting a framework for (1 − ε)-approximating any Max-k-CSP problem in sub-exponential time while significantly relaxing the denseness requirement on the input instance. Specifically, we prove that for any constants δ ∈ (0, 1] and ε > 0, we can approximate Max-k-CSP problems with Ω(n k−1+δ ) constraints within a factor of (1 − ε) in time 2 O(n 1−δ ln n/ε 3 ) . The framework is quite general and includes classical optimization problems, such as Max-CUT, Max-DICUT, Max-k-SAT, and (with a slight extension) k-Densest Subgraph, as special cases. For Max-CUT in particular (where k = 2), it gives an approximation scheme that runs in time sub-exponential in n even for "almostsparse" instances (graphs with n 1+δ edges). We prove that our results are essentially best possible, assuming the ETH. First, the density requirement cannot be relaxed further: there exists a constant r < 1 such that for all δ > 0, Max-k-SAT instances with O(n k−1 ) clauses cannot be approximated within a ratio better than r in time 2 O(n 1−δ ) . Second, the running time of our algorithm is almost tight for all densities. Even for Max-CUT there exists r < 1 such that for all δ ′ > δ > 0, Max-CUT instances with n 1+δ edges cannot be approximated within a ratio better than r in time 2 n 1−δ ′ .