func_code_string: #include <bits/stdc++.h>   using namespace std;   inline long long qr() {     register long long ret = 0, f = 0;     register char c = getchar();     while (c < 48 || c > 57) f |= c == 45, c = getchar();     while (c >= 48 && c <= 57) ret = ret * 10 + c - 48, c = getchar();     return f ? -ret : ret;   }   const int maxn = 1e5 + 5;   int n, m, p;   int dis[maxn];   long long sumd[maxn];   long long sumdata[maxn];   long long x[maxn];   long long y[maxn];   long long ans;   deque<int> q;   struct NODE {     int pos, time;     long long limit;     NODE() { ans = pos = time = 0; }     inline bool operator<(const NODE& a) const { return limit < a.limit; }     inline void scan() {       pos = qr();       time = qr();       limit = time - sumd[pos];     }   } data[maxn];   long long dp[101][maxn];   inline void wk() {     memset(dp, 5, sizeof dp);     dp[0][0] = 0;     deque<int>::iterator ita;     for (register int i = 0; i <= m; ++i) x[i] = i;     for (register int t = 1; t <= p; ++t) {       for (register int i = 0; i <= m; ++i) {         dp[t][i] = dp[t - 1][i];         y[i] = dp[t - 1][i] + sumdata[i];       }       q.clear();       for (register int i = 1; i <= m; ++i) {         q.push_back(i - 1);         ita = q.begin();         while (q.size() > 1 && y[*(ita + 1)] - y[*ita] <=                                    1ll * data[i].limit * ((*(ita + 1)) - (*ita)))           q.pop_front(), ita = q.begin();         register int j = q.front();         dp[t][i] = min(dp[t][i], dp[t - 1][j] + 1ll * (i - j) * data[i].limit -                                      (sumdata[i] - sumdata[j]));         ita = q.end() - 1;         while (q.size() > 1 &&                (y[*ita] - 1ll * y[*(ita - 1)]) * (i - (*ita)) >=                    1ll * (y[i] - y[*ita]) * ((*ita) - (*(ita - 1))))           q.pop_back(), ita = q.end() - 1;         ;       }     }     cout << dp[p][m] << endl;   }   int main() {     n = qr();     m = qr();     p = qr();     for (register int t = 2; t <= n; ++t) sumd[t] = (dis[t] = qr()) + sumd[t - 1];     for (register int t = 1; t <= m; ++t) data[t].scan();     sort(data + 1, data + m + 1);     for (register int t = 1; t <= m; ++t)       sumdata[t] = data[t].limit + sumdata[t - 1];     wk();     return 0;   }   