func_code_string: #include <bits/stdc++.h>   using namespace std;   struct ln {     long long m, k;     ln(long long mm, long long kk) {       m = mm;       k = kk;     }   };   deque<ln> cvt;   long long dp[100010][2];   long long sw[100010];   long long wt[100010];   long long hilldist[100010];   long long cs(long long x, int ci) { return x * cvt[ci].m + cvt[ci].k; }   bool ex(long long m, long long k) {     long long m1 = cvt[cvt.size() - 2].m;     long long k1 = cvt[cvt.size() - 2].k;     long long m2 = cvt[cvt.size() - 1].m;     long long k2 = cvt[cvt.size() - 1].k;     return (k1 - k2) * (m - m1) >= (k1 - k) * (m2 - m1);   }   int main() {     int n, m, p;     int d, h, t;     scanf( %d%d%d , &n, &m, &p);     for (int i = 2; i <= n; i++) {       scanf( %d , &d);       hilldist[i] = hilldist[i - 1] + d;     }     for (int i = 1; i <= m; i++) {       scanf( %d%d , &h, &t);       wt[i] = t - hilldist[h];     }     sort(wt + 1, wt + m + 1);     for (int i = 1; i <= m; i++) sw[i] = sw[i - 1] + wt[i];     int nx = 1, nw = 0;     for (int i = 1; i <= m; i++) {       dp[i][0] = wt[i] * i - sw[i];     }     int k1;     for (int k = 2; k <= p; k++) {       cvt.clear();       k1 = k - 1;       cvt.push_back(ln(-k1, sw[k1] + dp[k1][nw]));       for (int i = 0; i <= m; i++) dp[i][nx] = 0;       for (int i = k; i <= m; i++) {         while (cvt.size() > 1 && cs(wt[i], 0) >= cs(wt[i], 1)) cvt.pop_front();         dp[i][nx] = cs(wt[i], 0) + wt[i] * (i)-sw[i];         while (cvt.size() > 1 && ex(-i, sw[i] + dp[i][nw])) cvt.pop_back();         cvt.push_back(ln(-i, sw[i] + dp[i][nw]));       }       swap(nx, nw);     }     cout << dp[m][nw];   }   