Detalii evaluare #47921450

Rezumat problemă

La un festival sunt programate n spectacole. Pentru fiecare se cunoaște momentul de început și momentul de sfârșit, exprimate prin numere naturale. Un spectator dorește să urmărească cât mai multe spectacole în întregime.

Determinați numărul maxim de spectacole care pot fi urmărite, fără ca acestea să se suprapună.

Detalii

Problema Spectacole Operații I/O spectacole.in/spectacole.out
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #47921450 Utilizator Iov Denisa (denisa_iov)
Fișier spectacole.cpp Dimensiune 670 B
Data încărcării 10 Ianuarie 2024, 10:20 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

spectacole.cpp:3:19: warning: extra tokens at end of #include directive [enabled by default]
 #include <vector> struct Pair{ int start, end; }; 

                   ^
spectacole.cpp:4:10: error: 'Pair' was not declared in this scope
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
          ^
spectacole.cpp:4:18: error: 'Pair' was not declared in this scope
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                  ^
spectacole.cpp:4:24: error: expression list treated as compound expression in initializer [-fpermissive]
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                        ^
spectacole.cpp:4:26: error: expected ',' or ';' before '{' token
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                          ^
spectacole.cpp: In function 'int main()':
spectacole.cpp:4:115: error: 'Pair' was not declared in this scope
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                   ^
spectacole.cpp:4:119: error: template argument 1 is invalid
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                       ^
spectacole.cpp:4:119: error: template argument 2 is invalid
spectacole.cpp:4:125: error: invalid type in declaration before ';' token
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                             ^
spectacole.cpp:4:240: error: request for member 'reserve' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                ^
spectacole.cpp:4:274: error: expected ';' before 'tmp'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                  ^
spectacole.cpp:4:300: error: 'tmp' was not declared in this scope
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                            ^
spectacole.cpp:4:327: error: request for member 'push_back' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                       ^
spectacole.cpp:4:360: error: request for member 'begin' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                        ^
spectacole.cpp:4:374: error: request for member 'end' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                      ^
spectacole.cpp:4:423: error: request for member 'at' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                       ^
spectacole.cpp:4:445: error: request for member 'size' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
spectacole.cpp:4:464: error: request for member 'at' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ^
spectacole.cpp:4:498: error: request for member 'erase' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ^
spectacole.cpp:4:509: error: request for member 'begin' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^
spectacole.cpp:4:534: error: request for member 'size' in 'data', which is of non-class type 'int'
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ^
spectacole.cpp:4:233: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 bool cmp(Pair a, Pair b) { return a.end < b.end; } int main() { int n, count = 0, i = 0, currentTime; std::vector<Pair> data; FILE *in, *out; in = fopen("spectacole.in", "r"); out = fopen("spectacole.out", "w"); fscanf(in, "%d", &n); data.reserve(n); while(i++ < n) { Pair tmp; fscanf(in, "%d %d", &tmp.start, &tmp.end); data.push_back(tmp); } std::sort(data.begin(), data.end(), cmp); do { count += 1; currentTime = data.at(0).end; while(data.size() > 0 && data.at(0).start < currentTime) { data.erase(data.begin()); } } while(data.size() > 0); fprintf(out, "%d", count); }
                                                                                                                                                                                                                                         ^

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema Spectacole face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:

  • Programul sursă este compilat folosind compilatorul corespunzător. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Dacă programul a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.