# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
699141 |
2023-02-15T19:08:45 Z |
Ahmed57 |
Sticks (POI11_pat) |
C++14 |
|
275 ms |
12920 KB |
#include <bits/stdc++.h>
using namespace std;
vector<int> s[50];int b[50];
vector<pair<int,int>> v;
int ma1 = -1 , ma2 = 0 , ind1 = 0 , ind2 = 0 , x = 0 , d = 0 , n;
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
for(int i = 0;i<n;i++){
cin>>d;
for(int j = 0;j<d;j++){
cin>>x;
v.push_back({x,i});
s[i].push_back(x);
}
sort(s[i].begin(),s[i].end());
}
sort(v.begin(),v.end());
for(int i = 0;i<v.size();i++){
b[v[i].second] = -1;
for(int j = 0;j<n;j++){
if(j==v[i].second)continue;
int d = lower_bound(s[j].begin(),s[j].end(),v[i].first+1)-s[j].begin();
if(d>0){
b[j]=s[j][d-1];
}else b[j] = -1;
}
int ma1 = -1 , ind1 = 0 , ma2 = -1 , ind2 = 0;
for(int j = 0;j<n;j++){
if(ma1<b[j]){
ma1 = b[j];
ind1 = j;
}
}
if(ma1==-1)continue;
for(int j = 0;j<n;j++){
if(j==ind1)continue;
if(ma2<b[j]){
ma2 = b[j];
ind2 = j;
}
}
if(ma2==-1)continue;
if(ma1+ma2<=v[i].first)continue;
cout<<v[i].second+1<<" "<<v[i].first<<" "<<ind1+1<<" "<<ma1<<" "<<ind2+1<<" "<<ma2<<endl;
return 0;
}
cout<<"NIE"<<endl;
}
Compilation message
pat.cpp: In function 'int main()':
pat.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i = 0;i<v.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Oczekiwano NIE |
2 |
Correct |
8 ms |
828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Oczekiwano NIE |
2 |
Correct |
11 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Oczekiwano NIE |
2 |
Correct |
24 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
776 KB |
Oczekiwano NIE |
2 |
Correct |
39 ms |
3100 KB |
Output is correct |
3 |
Correct |
36 ms |
1876 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1744 KB |
Oczekiwano NIE |
2 |
Correct |
72 ms |
5716 KB |
Output is correct |
3 |
Correct |
69 ms |
3116 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
6664 KB |
Output is correct |
2 |
Correct |
95 ms |
5604 KB |
Output is correct |
3 |
Correct |
98 ms |
3756 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
6596 KB |
Output is correct |
2 |
Correct |
101 ms |
5820 KB |
Output is correct |
3 |
Correct |
160 ms |
5992 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
12684 KB |
Output is correct |
2 |
Correct |
115 ms |
5824 KB |
Output is correct |
3 |
Correct |
171 ms |
6956 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
12920 KB |
Output is correct |
2 |
Correct |
153 ms |
6276 KB |
Output is correct |
3 |
Correct |
238 ms |
11532 KB |
Oczekiwano NIE |