func_code_string: #include <bits/stdc++.h>   const long long mod = (long long)1e9 + 7;   const int maxn = (int)1e5 + 1;   long long inf = 1LL << 60;   using namespace std;   inline void read(int &n) {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = 10 * x + ch -  0 ;       ch = getchar();     }     n = x * f;   }   inline void read(long long &n) {     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 = 10ll * x + ch -  0 ;       ch = getchar();     }     n = x * f;   }   int a[20];   int rule[20][20];   long long dp[1 << 19][19];   int bitCount(int n) {     int count = 0;     while (n) {       count++;       n &= (n - 1);     }     return count;   }   int main() {     setlocale(LC_ALL,  Russian );     ios_base::sync_with_stdio(0);     int n, m, k;     cin >> n >> m >> k;     long long ans = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < k; i++) {       int u, v, d;       cin >> u >> v >> d;       u--, v--;       rule[u][v] = d;     }     for (int i = 0; i < n; i++) dp[1 << i][i] = a[i];     for (int mask = 0; mask < 1 << n; mask++) {       for (int i = 0; i < n; i++) {         if (mask & (1 << i)) {           for (int j = 0; j < n; j++) {             if (!(mask & (1 << j))) {               int nmask = mask | (1 << j);               dp[nmask][j] = max(dp[nmask][j], dp[mask][i] + a[j] + rule[i][j]);             }           }         }       }     }     for (int mask = 0; mask < 1 << n; mask++) {       for (int i = 0; i < n; i++) {         if (bitCount(mask) == m) {           ans = max(ans, dp[mask][i]);         }       }     }     cout << ans;     return 0;   }   