Submission #6663997


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, M, A[505][505], B[505][505];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, N) rep(j, 0, M) cin >> A[i][j];
	rep(i, 0, N) rep(j, 0, M) cin >> B[i][j];

	int t = 0;
	rep(i, 0, N) {
		int opt = inf;
		rep(j, 0, M) {
			int t2 = t;
			if (0 < t2 % A[i][j]) t2 += (A[i][j] - (t2 % A[i][j]));
			chmin(opt, t2 + B[i][j]);
		}
		t = opt;
	}
	cout << t << endl;
}




Submission Info

Submission Time
Task F - 不便な橋
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1764 Byte
Status
Exec Time 42 ms
Memory 2304 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s_01.txt
Subtask1 300 / 300 s_01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt
Case Name Status Exec Time Memory
02.txt 41 ms 2176 KB
03.txt 41 ms 2176 KB
04.txt 40 ms 2176 KB
05.txt 41 ms 2176 KB
06.txt 40 ms 2304 KB
07.txt 40 ms 2176 KB
08.txt 42 ms 2304 KB
09.txt 41 ms 2304 KB
10.txt 41 ms 2176 KB
s_01.txt 1 ms 256 KB