| Task: | Taulukko |
| Sender: | Narski |
| Submission time: | 2018-10-14 23:29:58 +0300 |
| Language: | C++ |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:22:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a.size()<=k)
~~~~~~~~^~~
input/code.cpp:25:17: error: expected ';' before 'if'
if(a.size() == k)
^~
input/code.cpp:29:17: error: expected '}' before 'else'
else if(a.size()>k)
^~~~
input/code.cpp:29:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(a.size()>k)
~~~~~~~~^~
input/code.cpp:39:13: error: 'else' without a previous 'if'
else
^~~~
input/code.cpp: At global scope:
input/code.cpp:46:5: error: 'cout' does not name a type
cout << tulos;
^~~~
input/code.cpp:48:5: error: expected unqualified-id before 'return'
return 0;
^~~~~~
input/code.cpp:49:1: error: expected declaration before '}' token
}
^Code
#include <iostream>
#include <unordered_set>
using namespace std;
int main()
{
long int n,k;
cin >> n;
cin >> k;
long int t[n];
unordered_set<long int> a;
long int tulos = 0;
for(long int i = 0;i<n;i++)
{
cin >> t[i];
}
for(long int j = 0; j<n; j++)
{
for(long int x = j; x<n ;x++)
{
if(a.size()<=k)
{
a.insert(t[x])
if(a.size() == k)
{
tulos++;
}
else if(a.size()>k)
{
break;
}
else
{
tulos++;
a.insert(t[x]);
}
}
else
{
break;
}
}
a.clear();
}
cout << tulos;
return 0;
}
