fun main(args: Array<String>?): Unit {
    val (n, t, s) = readLine()!!.trim().split(' ').map(String::toInt)
    val stores = Array(n){
        val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
        Store(a, b)
    }
    val memo = IntArray(t + 1){0}
    for (store in stores) {
        for (i in t - store.time downTo s)
            memo[i + store.time] = Math.max(memo[i] + store.benefit, memo[i + store.time])
        for (i in s - store.time downTo 0)
            memo[i + store.time] = Math.max(memo[i] + store.benefit, memo[i + store.time])
    }
    println(memo.max())
}
data class Store(val benefit: Int, val time: Int)
