답안 #796135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796135 2023-07-28T06:51:16 Z 이동현(#10071) Security Guard (JOI23_guard) C++17
0 / 100
10 ms 1876 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

int dp[1004];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(n);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];

        if(i && a[i] == a[i - 1]){
            ans += a[i];
        }
    }

    vector<int> chk(3);
    for(int i = 0; i < n; ++i){
        if(a[i] > 0){
            if(i && !chk[a[i]]) ++ans;
            chk[a[i]] = 1;
            
            int j = i;
            while(j + 1 < n && a[i] == a[j + 1]){
                ++j;
            }

            i = j;

            if(i + 1 < n){
                chk[a[i]] = 1;
                ++ans;
            }
        }
    }

    cout << ans << '\n';
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1876 KB Output is correct
3 Correct 9 ms 1876 KB Output is correct
4 Incorrect 10 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1876 KB Output is correct
3 Correct 9 ms 1876 KB Output is correct
4 Incorrect 10 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1876 KB Output is correct
3 Correct 9 ms 1876 KB Output is correct
4 Incorrect 10 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1876 KB Output is correct
3 Correct 9 ms 1876 KB Output is correct
4 Incorrect 10 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 1876 KB Output is correct
3 Correct 9 ms 1876 KB Output is correct
4 Incorrect 10 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -