Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
99 lines (80 loc) · 1.58 KB

File metadata and controls

99 lines (80 loc) · 1.58 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define DEBUG
#define REP(i,a) for(i=0;i<a;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define VE vector<int>
#define SZ size()
#define PB push_back
const int MAXN = 105;
int data[MAXN][MAXN];
int N;
void trans(){
for(int i=0; i<N; i++){
for(int j=i+1; j<N; j++){
swap(data[i][j], data[j][i]);
}
}
}
bool single_ride(int car){
int n_cur = 0;
for(int row=0; row<N; row++){
for(int i=row+1; i<N; i++){
n_cur += data[row][i];
}
for(int i=row-1; i>=0; i--){
n_cur -= data[i][row];
}
if(n_cur > car*36){
return false;
}
}
return true;
}
bool judge(int car){
bool ok=false;
if(single_ride(car)){
trans();
if(single_ride(car)){
ok = true;
}
trans();
}
if(ok)return true;
return false;
}
void work(){
int car = 10;
//cout<<car<<" "<<judge(car)<<endl;
int low = 0, high = 100000000;
int ans = -1;
while(low<high){
//cout<<"low "<<low<<" high "<<high<<endl;
int mid = (high+low)/2;
if(judge(mid)){
ans = mid;
high = mid;
}else{
low = mid+1;
}
}
cout<<ans<<endl;
}
int main(){
cin>>N;
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
cin>>data[i][j];
}
}
work();
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.