# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85377 | tjdgus4384 | 조화행렬 (KOI18_matrix) | C++14 | 9 ms | 500 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, pair<int, int> > > v;
vector<int> vf;
vector<int> vs;
int main()
{
int m, n, x;
scanf("%d %d",&m, &n);
v.resize(n);
for(int i = 0;i < m;i++)
{
for(int j = 0;j < n;j++)
{
scanf("%d", &x);
if(i == 0) v[j].first = x;
if(i == 1) v[j].second.first = x;
if(i == 2) v[j].second.second = x;
if(i == 0 && m == 2) v[j].second.second = v[j].first;
}
}
sort(v.begin(), v.end());
vf.push_back({-1000000000});
vs.push_back({-1000000000});
for(int i = 0;i < n;i++)
{
int f = v[i].second.first;
int s = v[i].second.second;
if(f > vf.back() && s > vs.back())
{
vf.push_back(f);
vs.push_back(s);
}
else
{
int fx = lower_bound(vf.begin(), vf.end(), f) - vf.begin();
int sx = lower_bound(vs.begin(), vs.end(), s) - vs.begin();
fx = max(fx, sx);
sx = fx;
vf[fx] = f;
vs[sx] = s;
}
}
printf("%d", vf.size() - 1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |