답안 #897572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897572 2024-01-03T12:35:20 Z bleahbleah Security Guard (JOI23_guard) C++17
25 / 100
24 ms 4192 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

vector<int> S;

signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  int n, m, q;
  cin >> n >> m >> q;
  S.resize(n);
  
  for(auto &x : S) cin >> x;
  
  //reverse(all(S));
  
  ll sum = 0;
  
  for(int i = 0; i < n - 1; i++)
    sum += (S[i] == S[i + 1]) * S[i];
  S.erase(unique(all(S)), end(S));
  
  n = sz(S);
  
  int mx = *max_element(all(S));
  
  int revers = S[0] == mx;
  
  for(int i = 0; i < n - 1; i++) {
    if(revers == 0) {
      sum += S[i + 1];
      if(S[i + 1] == mx)
        revers = 1;
    }
    else if(revers) {
      sum += S[i];
    }
  }
  
  cout << sum << '\n';
  
  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 9 ms 2652 KB Output is correct
3 Correct 14 ms 2652 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 9 ms 2652 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 12 ms 2648 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 9 ms 2652 KB Output is correct
3 Correct 14 ms 2652 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 9 ms 2652 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 12 ms 2648 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 24 ms 3936 KB Output is correct
11 Correct 17 ms 4184 KB Output is correct
12 Correct 17 ms 3924 KB Output is correct
13 Correct 17 ms 4172 KB Output is correct
14 Correct 17 ms 3944 KB Output is correct
15 Correct 19 ms 4192 KB Output is correct
16 Correct 17 ms 4048 KB Output is correct
17 Correct 17 ms 3940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 9 ms 2652 KB Output is correct
3 Correct 14 ms 2652 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 9 ms 2652 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 12 ms 2648 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 24 ms 3936 KB Output is correct
11 Correct 17 ms 4184 KB Output is correct
12 Correct 17 ms 3924 KB Output is correct
13 Correct 17 ms 4172 KB Output is correct
14 Correct 17 ms 3944 KB Output is correct
15 Correct 19 ms 4192 KB Output is correct
16 Correct 17 ms 4048 KB Output is correct
17 Correct 17 ms 3940 KB Output is correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 9 ms 2652 KB Output is correct
3 Correct 14 ms 2652 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 9 ms 2652 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 12 ms 2648 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 24 ms 3936 KB Output is correct
11 Correct 17 ms 4184 KB Output is correct
12 Correct 17 ms 3924 KB Output is correct
13 Correct 17 ms 4172 KB Output is correct
14 Correct 17 ms 3944 KB Output is correct
15 Correct 19 ms 4192 KB Output is correct
16 Correct 17 ms 4048 KB Output is correct
17 Correct 17 ms 3940 KB Output is correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 9 ms 2652 KB Output is correct
3 Correct 14 ms 2652 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 9 ms 2652 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 12 ms 2648 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 24 ms 3936 KB Output is correct
11 Correct 17 ms 4184 KB Output is correct
12 Correct 17 ms 3924 KB Output is correct
13 Correct 17 ms 4172 KB Output is correct
14 Correct 17 ms 3944 KB Output is correct
15 Correct 19 ms 4192 KB Output is correct
16 Correct 17 ms 4048 KB Output is correct
17 Correct 17 ms 3940 KB Output is correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -