func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   char buf[1 << 15], *fs, *ft;   inline char getc() {     return (ft == fs &&             (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), ft == fs))                ? 0                : *fs++;   }   template <typename T>   inline void read(T &x) {     x = 0;     T f = 1, ch = getchar();     while (!isdigit(ch) && ch ^  - ) ch = getchar();     if (ch ==  - ) f = -1, ch = getchar();     while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     x *= f;   }   template <typename T>   inline void write(T &x) {     if (!x) {       putchar( 0 ), putchar(  n );       return;     }     if (x < 0) putchar( - ), x = -x;     T num = 0, ch[16];     while (x) ch[++num] = x % 10 + 48, x /= 10;     while (num) putchar(ch[num--]);     putchar(  n );   }   int q[maxn], now;   long long f[2][maxn], a[maxn], d[maxn], sum[maxn];   inline long long getUp(int j, int k) {     return (f[now ^ 1][j] + sum[j]) - (f[now ^ 1][k] + sum[k]);   }   inline long long getDw(int j, int k) { return j - k; }   int main() {     int n, m, p;     read(n);     read(m);     read(p);     for (int i = 2; i <= n; ++i) read(d[i]), d[i] += d[i - 1];     for (int i = 1; i <= m; ++i) {       int h;       long long t;       read(h);       read(t);       a[i] = t - d[h];     }     sort(a + 1, a + m + 1);     for (int i = 1; i <= m; ++i) sum[i] = sum[i - 1] + a[i], f[0][i] = 1e18;     long long ans = 1e18;     now = 1;     for (int t = 1; t <= p; ++t) {       int l = 1, r = 1;       q[1] = 0;       for (int i = 1; i <= m; ++i) {         while (l < r && getUp(q[l + 1], q[l]) <= a[i] * getDw(q[l + 1], q[l]))           ++l;         f[now][i] = f[now ^ 1][q[l]] + (long long)a[i] * (i - q[l]) -                     (sum[i] - sum[q[l]]);         while (l < r && getUp(i, q[r]) * getDw(q[r], q[r - 1]) <=                             getUp(q[r], q[r - 1]) * getDw(i, q[r]))           --r;         q[++r] = i;       }       ans = min(ans, f[now][m]);       now ^= 1;     }     write(ans);     return 0;   }   