Submission #24330925
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main () {
int N, K;
cin >> N >> K;
vector<int> color(N);
for (int i = 0; i < N; i++) {
cin >> color.at(i);
}
int Yoro = 0;
map<int, int> M;
for (int i = 0; i < K; i++) {
M[color.at(i)] += 1;
}
for (int i = 0; i < N - K; i++) {
M[color.at(i)] -= 1;
M[color.at(i + K)] += 1;
if (M[color.at(i)] == 0) {
M.erase(color.at(i));
}
if (Yoro <= M.size()) {
Yoro = M.size();
}
}
cout << Yoro << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Colorful Candies |
| User | Awes |
| Language | C++ (GCC 9.2.1) |
| Score | 0 |
| Code Size | 637 Byte |
| Status | WA |
| Exec Time | 230 ms |
| Memory | 18468 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:28:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::map<int, int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
28 | if (Yoro <= M.size()) {
| ~~~~~^~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, example0.txt, example1.txt, example2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | WA | 1 ms | 3432 KiB |
| 001.txt | AC | 106 ms | 4204 KiB |
| 002.txt | AC | 109 ms | 4152 KiB |
| 003.txt | AC | 94 ms | 4200 KiB |
| 004.txt | AC | 107 ms | 4564 KiB |
| 005.txt | WA | 206 ms | 18468 KiB |
| 006.txt | WA | 182 ms | 13068 KiB |
| 007.txt | WA | 99 ms | 4244 KiB |
| 008.txt | AC | 224 ms | 9052 KiB |
| 009.txt | AC | 222 ms | 8728 KiB |
| 010.txt | AC | 230 ms | 9436 KiB |
| 011.txt | AC | 206 ms | 7908 KiB |
| 012.txt | AC | 95 ms | 4092 KiB |
| 013.txt | WA | 94 ms | 4156 KiB |
| 014.txt | AC | 95 ms | 4204 KiB |
| 015.txt | AC | 95 ms | 4212 KiB |
| 016.txt | AC | 98 ms | 8824 KiB |
| 017.txt | AC | 80 ms | 7384 KiB |
| 018.txt | AC | 99 ms | 4468 KiB |
| 019.txt | AC | 120 ms | 4876 KiB |
| 020.txt | AC | 145 ms | 10108 KiB |
| example0.txt | AC | 3 ms | 3416 KiB |
| example1.txt | WA | 2 ms | 3520 KiB |
| example2.txt | AC | 2 ms | 3516 KiB |