Submission #2514141
Source Code Expand
#include<iostream> #include<algorithm> #include<stack> #include<vector> using namespace std; int N; vector<int> A; stack<int> s; stack<int> rst; int main() { cin >> N; for (int i = 0, a; i < N; i++) { cin >> a; A.push_back(a); } sort(A.begin(), A.end()); for (int i = 0; i < N; i++) { s.push(A[i]); } int tmp1 = -1, tmp2 = -1; while (!s.empty()) { if (tmp1 < 1) { tmp1 = s.top(); s.pop(); if (!s.empty()) { if (tmp1 != s.top()) { rst.push(tmp1); tmp1 = -1; } else { s.pop(); } } } else if (tmp2 < 1) { tmp2 = s.top(); s.pop(); } else { if (tmp1 == tmp2 || tmp2 == s.top()) { s.push(tmp1); tmp1 = -1; tmp2 = -1; } else { rst.push(tmp2); tmp2 = -1; } } // cout << tmp1 << " " << tmp2 << endl; } if (tmp1 > 0 && tmp2 > 0) { rst.push(tmp1); } else if (tmp1 > 0) { rst.pop(); rst.push(tmp1); } // while (!rst.empty()) { // cout << rst.top() << endl; // rst.pop(); // } cout << rst.size() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Card Eater |
User | mmclsntr |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1212 Byte |
Status | WA |
Exec Time | 35 ms |
Memory | 1020 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 3 ms | 256 KB |
03.txt | WA | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 33 ms | 1020 KB |
07.txt | AC | 33 ms | 1020 KB |
08.txt | AC | 35 ms | 1020 KB |
09.txt | AC | 33 ms | 1020 KB |
10.txt | AC | 33 ms | 1020 KB |
11.txt | AC | 35 ms | 1020 KB |
12.txt | AC | 33 ms | 1020 KB |
13.txt | AC | 35 ms | 1020 KB |
14.txt | WA | 31 ms | 1020 KB |
15.txt | AC | 31 ms | 1020 KB |