Please open Telegram to view this post
VIEW IN TELEGRAM
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
ll X;
cin >> N >> M >> X;
vector<vector<ll>> G(N, vector<ll>(M));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> G[i][j];
}
}
ll ans = INF;
vector<vector<ll>> dp(N, vector<ll>(M, INF));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
if (i > 0) {
dp[i][j] = min(dp[i][j], dp[i-1][j]);
}
if (j > 0) {
dp[i][j] = min(dp[i][j], dp[i][j-1]);
}
if (dp[i][j] != INF) {
ll cost = G[i][j] + X * (i + j) + dp[i][j];
ans = min(ans, cost);
}
dp[i][j] = min(dp[i][j], G[i][j] - X * (i + j));
}
}
dp.assign(N, vector<ll>(M, INF));
for (int i = 0; i < N; ++i) {
for (int j = M-1; j >= 0; --j) {
if (i > 0) {
dp[i][j] = min(dp[i][j], dp[i-1][j]);
}
if (j + 1 < M) {
dp[i][j] = min(dp[i][j], dp[i][j+1]);
}
if (dp[i][j] != INF) {
ll cost = G[i][j] + X * (i - j) + dp[i][j] + X * 2 * j;
ans = min(ans, cost);
}
dp[i][j] = min(dp[i][j], G[i][j] - X * (i - j));
}
}
cout << ans << "\n";
return 0;
}
Adobe
Please open Telegram to view this post
VIEW IN TELEGRAM
πΌ Infosys Offline Interview Coding Support Completed π―
Test Successfully Accomplished πβ | SP Role
Complete Placement Support
Available (OA β Interview β Offer)
Contact π©
@Mrtrueliving_ix
#Infosys #OfflineDrive #InterviewSuccess
Review π
https://t.me/code_alphix/5444
Wipro Elite Help Available.....
@Mrtrueliving_ixβ
β
π
All slots are Available.....π»
OA + SVAR + INTERVIEW+ milestoneβοΈ
Upto onboarding processβ
β€οΈπ
@Mrtrueliving_ix
All slots are Available.....
OA + SVAR + INTERVIEW+ milestone
Upto onboarding process
https://t.me/code_alphix/6587
Please open Telegram to view this post
VIEW IN TELEGRAM
π Placement Season Alert π―
Crack these top hiring challenges with confidence:
π» Infosys HackWithInfy
π₯ Infosys SP
π Flipkart GRiD
πΌ Wipro Talent Hunt
π― Hereβs the Official Discussion Page:
Post your coding questions, share ideas & get help!
π https://t.me/code_alphix2
π https://t.me/code_alphix
π€ Join now & invite your friends too!
β 100% Verified Support
#HelpThemToSucceed π―
β€3
πβ¨ 2025 Placement Season is Heating Up!
Your dream job is just one test away β are YOU ready to crack it?
π Full Support Available For:
πΉ Infosys SP β July 13th
πΉ Wipro Elite β July 13th
πΉ Flipkart Grid
πΉ Capgemini β July 13th
πΉ HackWithInfy
πΉ Adobe | Amazon SDE | ServiceNow
πΉ Many More Hiring Drives Coming Up!
π» What You Get:
β Plag-Free & Optimized Coding Solutions
β One-on-One Guidance Before the Test
β High Success Rate with Trusted Mentorship
β Last-Minute Doubt Solving
π Trusted by Hundreds | Results That Speak π
π© DM now π @Mrtrueliving_ix
@Mrtrueliving_ix
π Donβt wait for luck. Prepare smart. Win big.
π’ Share this with your friends β Help them succeed too!
β€4
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Infosys Hackwithinfyπ― β 10 Am
Saty tuned
DM for codes
@Mrtrueliving_ix
@Mrtrueliving_ix
Only verified codes | π― Plagfree
Please open Telegram to view this post
VIEW IN TELEGRAM
π«‘1
Infosys Hackwithinfyβ
π¬ 3/3 codes are done πΈ
Test accomplishedπ» π±
All placement help available
DM @MRTRUELIVING_IXβοΈ
@MRTRUELIVING_IXβοΈ
#Infosys #Hackwithinfy #offcampus
Slot -1
Test accomplished
All placement help available
DM @MRTRUELIVING_IX
@MRTRUELIVING_IX
#Infosys #Hackwithinfy #offcampus
Please open Telegram to view this post
VIEW IN TELEGRAM
β€1πΎ1
Infosys Hackwithinfyβ
Test accomplishedπ» π±
All placement help available
DM @MRTRUELIVING_IXβοΈ
@MRTRUELIVING_IXβοΈ
#Infosys #Hackwithinfy #offcampus
Slot -2
π¬ 2.9/3 codes are doneπΈ
Test accomplished
All placement help available
DM @MRTRUELIVING_IX
@MRTRUELIVING_IX
#Infosys #Hackwithinfy #offcampus
Please open Telegram to view this post
VIEW IN TELEGRAM
β€1
Infosys Hackwithinfyβ
Test accomplishedπ» π±
All placement help available
DM @MRTRUELIVING_IXβοΈ
@MRTRUELIVING_IXβοΈ
#Infosys #Hackwithinfy #offcampus
Slot 3& 4
Test accomplished
All placement help available
DM @MRTRUELIVING_IX
@MRTRUELIVING_IX
#Infosys #Hackwithinfy #offcampus
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯2
Hackwithinfy 3 pm Slots are available
DM @Mrtrueliving_ix
π― Test clearance with shortlist for next round
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π All Placement Help Available! π―
π― Wipro Elite
π― Flipkart Grid
π― Capgemini
π― Zeta
π― Kairos
π― Infosys SP
π― Goldman Sachs (GS)
π― Oracle
π§ Plag-Free Codes | πΌ Role-Based Guidance | β High Success Rate
π© DM @Mrtrueliving_ix to get started now
β€1
Wipro Elite 9 Am help available....
DM @Mrtrueliving_ix
Full process up to onboarding
OA + communication + interview + milestone
Limited slots are available
Please open Telegram to view this post
VIEW IN TELEGRAM
π«‘1
Please open Telegram to view this post
VIEW IN TELEGRAM
Wipro 9 Am Help doneβοΈ π β
DM @Mrtrueliving_ix for test clearance
Test accomplished β€οΈ
#Wipro #Offcampus #2025Batch
All sections are Done
Please open Telegram to view this post
VIEW IN TELEGRAM