I have been trying some practise questions but codechef ide is giving same error for every code. Even for the codes already submitted for the question. Here is my code that's coming with the error in codechef ide. Any other submitted code I tried gives me same error !
#include<iostream>
using namespace std;
int main() {
long long int n;
cin>>n;
long long int c[n], t[n];
for(int i=0;i<n;i++) {
cin>>c[i];
}
for(int i=0;i<n;i++) {
cin>>t[i];
}
long long int tr = -1, a = -1, b = -1;
for(int i=0;i<n;i++) {
if(t[i] == 1) {
if(tr == -1 || tr > c[i]) {
tr = c[i];
}
}
else if(t[i] == 2) {
if(a == -1 || a > c[i]) {
a = c[i];
}
}
else {
if(b == -1 || b > c[i]) {
b = c[i];
}
}
}
if(tr == -1 || a == -1) {
cout<<b<<endl;
}
else if(b == -1 || tr+a < b) {
cout<<tr+a<<endl;
}
else {
if(tr+a > b) {
cout<<b<<endl;
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire