Task: | Taulukko |
Sender: | tuomask |
Submission time: | 2018-10-10 21:17:19 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:5:9: error: 'll' does not name a type typedef ll long long; ^~ input/code.cpp:8:1: error: 'll' does not name a type ll x[500000]; ^~ input/code.cpp:10:13: error: 'll' was not declared in this scope bool loytyy(ll a, int alku, int loppu) { ^~ input/code.cpp:10:19: error: expected primary-expression before 'int' bool loytyy(ll a, int alku, int loppu) { ^~~ input/code.cpp:10:29: error: expected primary-expression before 'int' bool loytyy(ll a, int alku, int loppu) { ^~~ input/code.cpp:10:38: error: expression list treated as compound expression in initializer [-fpermissive] bool loytyy(ll a, int alku, int loppu) { ^ input/code.cpp: In function 'int main()': input/code.cpp:19:34: error: 'x' was not declared in this scope for (int i=0; i<n; i++) cin >> x[i]; ^ input/code.cpp:25:19: error: 'x' was not declared in this scope...
Code
#include <bits/stdc++.h>using namespace std;typedef ll long long;int n,k;ll x[500000];bool loytyy(ll a, int alku, int loppu) {for (int i=alku; i<loppu; i++) {if (x[i] == a) return true;}return false;}int main() {cin >> n >> k;for (int i=0; i<n; i++) cin >> x[i];int s=0, eri=0, a=0, b=0;while (a < n) {// siirretään ylärajaa niin pitkälle kuin voidaanwhile (b < n && eri <= k) {// uutta ylintä lukua ei löydy aiemmista luvuista,if (!loytyy(x[b], a, b)) {if (eri == k) break;// korotetaan erilaisten lukujen määrääeri++;}b++;}s += b-a;// siirretään alarajaall eka = x[a];a++;// jos poistettava eka luku ei löydy muualta,// vähennetään erilaisten lukujen määrääif (!loytyy(eka, a, b)) eri--;}cout << s << "\n";}