답안 #491620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491620 2021-12-03T14:34:15 Z blue Baloni (COCI15_baloni) C++17
100 / 100
262 ms 3912 KB
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

    multiset<int> arr;

    for(int i = 1; i <= N; i++)
    {
        int H;
        cin >> H;

        // cerr << "curr set: ";
        // for(int a:arr) cerr << a << ' ';
        // cerr << '\n';

        if(arr.find(H) == arr.end())
        {
            // cerr << "inserting " << H-1 << '\n';
            arr.insert(H-1);
        }
        else
        {
            arr.erase(arr.find(H));
            arr.insert(H-1);
            // cerr << "dropping to " << H-1 << '\n';
        }
    }

    cout << int(arr.size()) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 213 ms 3912 KB Output is correct
6 Correct 262 ms 3868 KB Output is correct
7 Correct 224 ms 3248 KB Output is correct
8 Correct 214 ms 3236 KB Output is correct
9 Correct 224 ms 3528 KB Output is correct
10 Correct 239 ms 3464 KB Output is correct