#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
void fastscan(int &n)
{
bool minus=false;
n=0;
register int c=getchar();
if(c=='-')
{
minus=true;
c=getchar();
}
while(c>='0'&&c<='9')
{
n*=10;
n+=c-'0';
c=getchar();
}
if(minus)
n*=-1;
}
int k,i,n,j,a,p,m1,m2,c1,c2,ma1,ma2,ca1,ca2,l,r,mid,v,dd;
int main()
{
//scanf("%i",&k);
fastscan(k);
vector<vector<int> > sets(k);
for(i=0;i<k;i++)
{
sets[i].pb(INT_MAX);
//scanf("%i",&n);
fastscan(n);
for(j=0;j<n;j++)
{
//scanf("%i",&a);
fastscan(a);
sets[i].pb(a);
}
sort(sets[i].begin(),sets[i].end());
}
for(i=0;i<k;i++)
{
for(dd=0;dd<sets[i].size();dd++)
{
p=sets[i][dd];
if(p==INT_MAX)
continue;
m1=INT_MAX;m2=INT_MAX;
ma1=-1;ma2=-1;
for(j=0;j<k;j++)
{
if(i==j)
continue;
l=0,r=sets[j].size()-1;
while(l<r)
{
mid=(l+r)/2;
if(mid==0&&sets[j][mid]>=p)
{
l=mid;
break;
}
if(sets[j][mid]>=p&&sets[j][mid-1]<p){
l=mid;
break;
}
if(sets[j][mid]<p)
{
l=mid+1;
}
else
{
r=mid;
}
}
v=sets[j][l];
if(v<m1)
{
m2=m1;
c2=c1;
m1=v;
c1=j;
}
else
{
if(v<m2)
{
m2=v;
c2=j;
}
}
if(l==0)
continue;
v=sets[j][l-1];
if(v>ma1)
{
ma2=ma1;
ca2=ca1;
ma1=v;
ca1=j;
}
else
{
if(v>ma2)
{
ma2=v;
ca2=j;
}
}
}
if(m1!=INT_MAX&&m2!=INT_MAX)
{
if(p+m1>m2)
{
printf("%i %i %i %i %i %i\n",i+1,p,c1+1,m1,c2+1,m2);
return 0;
}
}
if(ma1!=-1&&ma2!=-1)
{
if(ma1+ma2>p)
{
printf("%i %i %i %i %i %i\n",i+1,p,ca1+1,ma1,ca2+1,ma2);
return 0;
}
}
}
}
printf("NIE\n");
return 0;
}
Compilation message
pat.cpp: In function 'int main()':
pat.cpp:48:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(dd=0;dd<sets[i].size();dd++)
~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
452 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
476 KB |
Oczekiwano NIE |
2 |
Correct |
8 ms |
924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
924 KB |
Oczekiwano NIE |
2 |
Correct |
16 ms |
1264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1264 KB |
Oczekiwano NIE |
2 |
Correct |
18 ms |
2548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2548 KB |
Oczekiwano NIE |
2 |
Correct |
27 ms |
4240 KB |
Output is correct |
3 |
Correct |
51 ms |
4868 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
5132 KB |
Oczekiwano NIE |
2 |
Correct |
46 ms |
8256 KB |
Output is correct |
3 |
Correct |
87 ms |
9060 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
10688 KB |
Output is correct |
2 |
Correct |
79 ms |
10688 KB |
Output is correct |
3 |
Correct |
129 ms |
11748 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
12448 KB |
Output is correct |
2 |
Correct |
101 ms |
12448 KB |
Output is correct |
3 |
Correct |
191 ms |
14128 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
23112 KB |
Output is correct |
2 |
Correct |
193 ms |
24356 KB |
Output is correct |
3 |
Correct |
234 ms |
28600 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
30212 KB |
Output is correct |
2 |
Correct |
84 ms |
32204 KB |
Output is correct |
3 |
Runtime error |
366 ms |
33792 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |