답안 #796137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796137 2023-07-28T06:52:53 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] == 2){
            if(i && !chk[2]) ++ans;
            chk[2] = 1;

            int j = i;
            while(j + 1 < n && 2 == a[j + 1]){
                ++j;
            }

            i = j;

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

            i = j;

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

    cout << ans << '\n';
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 0 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 0 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 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 -