func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, m, p, d[100005], sum[100005], f[105][100005], s[100005], a[100005],       q[100005], head, tail, g[100005];   inline long long getint() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   void work() {     n = getint(), m = getint(), p = getint();     for (int i = 2; i <= n; ++i) d[i] = getint(), sum[i] = sum[i - 1] + d[i];     for (int i = 1; i <= m; ++i) {       int x, y;       x = getint(), y = getint();       a[i] = y - sum[x];     }     sort(a + 1, a + 1 + m);     for (int i = 1; i <= m; ++i) s[i] = s[i - 1] + a[i];     memset(f, 0x3f, sizeof(f));     f[0][0] = 0;     for (int i = 1; i <= p; ++i) {       for (int j = 1; j <= m; ++j) g[j] = f[i - 1][j] + s[j];       head = 1, tail = 1;       q[1] = 0;       for (int j = 1; j <= m; ++j) {         while (head < tail &&                g[q[head + 1]] - g[q[head]] <= a[j] * (q[head + 1] - q[head]))           ++head;         f[i][j] = min(f[i - 1][j], g[q[head]] + a[j] * (j - q[head]) - s[j]);         if (g[j] >= 0x3f3f3f3f3f3f3f3fll) continue;         while (head < tail && (g[j] - g[q[tail]]) * (q[tail] - q[tail - 1]) <=                                   (g[q[tail]] - g[q[tail - 1]]) * (j - q[tail]))           --tail;         q[++tail] = j;       }     }     cout << f[p][m] << endl;   }   int main() {     work();     return 0;   }   