codeforces#FF(div2) D DZY Loves Modification_html/css_WEB-ITnose
首先要知道选择行列操作时顺序是无关的
用两个数组row[i],col[j]分别表示仅选择i行能得到的最大值和仅选择j列能得到的最大值
这个用优先队列维护,没选择一行(列)后将这行(列)的和减去相应的np (mp)重新加入队列
枚举选择行的次数为i,那么选择列的次数为k - i次,ans = row[i] + col[k - i] - (k - i) * i * p;
既然顺序无关,可以看做先选择完i次行,那么每次选择一列时都要减去i * p,选择k - i次列,即减去(k - i) * i * p
//#pragma comment(linker, "/STACK:102400000,102400000")//HEAD#include <cstdio>#include <cstring>#include <vector>#include <iostream>#include <algorithm>#include <queue>#include <string>#include <set>#include <stack>#include <map>#include <cmath>#include <cstdlib>using namespace std;//LOOP#define FE(i, a, b) for(int i = (a); i = (a); --i)#define REP(i, N) for(int i = 0; i = (a); --i)#define CPY(a, b) memcpy(a, b, sizeof(a))#define FC(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)#define EQ(a, b) (fabs((a) - (b)) VI;typedef unsigned long long ULL;typedef long long LL;const int INF = 0x3f3f3f3f;const int maxn = 1010;const double eps = 1e-10;const LL MOD = 1e9 + 7;int ipt[maxn][maxn];LL row[maxn * maxn], col[maxn * maxn];LL rtol[maxn], ctol[maxn];int main(){ int n, m, k, p; while (~RIV(n, m, k, p)) { priority_queue<ll> r, c; int radd = 0, cadd = 0; CLR(rtol, 0), CLR(ctol, 0); FE(i, 1, n) FE(j, 1, m) { RI(ipt[i][j]); rtol[i] += ipt[i][j]; ctol[j] += ipt[i][j]; } FE(i, 1, n) r.push(rtol[i]); FE(j, 1, m) c.push(ctol[j]); row[0] = 0, col[0] = 0; FE(i, 1, k) { LL x = r.top(), y = c.top(); r.pop(), c.pop(); r.push(x - m * p); c.push(y - n * p); row[i] = row[i - 1] + x; col[i] = col[i - 1] + y; }// FE(i, 0, k)// cout <br> <br> <p></p> </ll></cstdlib></cmath></map></stack></set></string></queue></algorithm></iostream></vector></cstring></cstdio>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

本文討論了HTML&lt; Progress&gt;元素,其目的,樣式和與&lt; meter&gt;元素。主要重點是使用&lt; progress&gt;為了完成任務和LT;儀表&gt;對於stati

本文討論了html&lt; datalist&gt;元素,通過提供自動完整建議,改善用戶體驗並減少錯誤來增強表格。Character計數:159

本文討論了HTML&lt; meter&gt;元素,用於在一個範圍內顯示標量或分數值及其在Web開發中的常見應用。它區分了&lt; meter&gt;從&lt; progress&gt;和前

本文討論了使用HTML5表單驗證屬性,例如必需的,圖案,最小,最大和長度限制,以直接在瀏覽器中驗證用戶輸入。

本文討論了視口元標籤,這對於移動設備上的響應式Web設計至關重要。它解釋瞭如何正確使用確保最佳的內容縮放和用戶交互,而濫用可能會導致設計和可訪問性問題。

本文討論了&lt; iframe&gt;將外部內容嵌入網頁,其常見用途,安全風險以及諸如對象標籤和API等替代方案的目的。

GiteePages靜態網站部署失敗:404錯誤排查與解決在使用Gitee...
