3508 | 2023-02-28 14:22:28 | váááá | Találkozás | cpp11 | Forditási hiba |
#include <iostream>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL)
double n;
cin >> n;
int be[100001] = {};
int ki[100001] = {};
string a;
int bek;
int kik;
int max = 0;
for (int i = 0; i < n; i++)
{
cin >> bek;
cin >> kik;
if (be[bek] == 0)
be[bek] = 1;
else
be[bek]++;
if (ki[kik] == 0)
ki[kik] = 1;
else
ki[kik]++;
if (max < kik)
max = kik + 1;
}
be[0] = 0;
ki[0] = 0;
int k = 0, v = 0, jk = 0, jv = 0, mint = INT_MAX, bent = 0, benttemp = 0;
bool volt = false;
while (v < max - 1)
{
v++;
bent += be[v];
int j = 2;
while (bent >= n / 2)
{
volt = true;
k++;
benttemp = bent;
bent -= ki[k - 1];
}
if (volt)
{
k--;
volt = false;
bent = benttemp;
if (mint > v - k)
{
jk = k;
jv = v;
mint = v - k;
}
}
}
cout << mint + 1 << endl;
cout << jk << " " << jv << endl;
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:9:18: error: expected ';' before 'double'
9 | cin.tie(NULL)
| ^
| ;
10 | double n;
| ~~~~~~
main.cpp:11:12: error: 'n' was not declared in this scope
11 | cin >> n;
| ^
main.cpp:42:46: error: 'INT_MAX' was not declared in this scope
42 | int k = 0, v = 0, jk = 0, jv = 0, mint = INT_MAX, bent = 0, benttemp = 0;
| ^~~~~~~
main.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
1 | #include <iostream>
+++ |+#include <climits>
2 | #include <string>
main.cpp:48:9: error: 'bent' was not declared in this scope
48 | bent += be[v];
| ^~~~
main.cpp:55:13: error: 'benttemp' was not declared in this scope
55 | benttemp = bent;
| ^~~~~~~~
main.cpp:63:20: error: 'benttemp' was not declared in this scope
...