답안 #781731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781731 2023-07-13T10:27:43 Z devariaota 이상한 기계 (APIO19_strange_device) C++17
10 / 100
1081 ms 17040 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

vector<pll> vec;
// {Left, Right}
ll n, a, b, length, ans = 0;

void opr(ll l, ll r) {
  ll pushl = l;
  ll pushr = r;

  if (pushl == 0) {
    // pushl = length;
  }

  if (pushr == 0) {
    // pushr = length;
  }

  vec.push_back({pushl, pushr});
}

void answer() {
  sort(vec.begin(), vec.end());

  ll idx = -1;
  for (int i = 0; i < vec.size(); ++i)
  {
    // cout << vec[i].first << " " << vec[i].second << "\n";
    pll now = vec[i];

    if (idx >= now.first)
    {
      if (now.second <= idx)
      {
        continue ;
      } else {
        idx++;
        ans += now.second - idx + 1;
        idx = now.second;
      }
    } else {
      idx = now.first;
      ans += now.second - idx + 1;
      idx = now.second;
    }
  }

  cout << ans << "\n";
}

int main(){
  cin >> n >> a >> b;
  unsigned long long lebek;
  if (a == 1) {
    lebek = b;
  } else {
    if (a % 2)
    {
      lebek = a * b;
    } else {
      lebek = (a/2) * b;
    }
  }

  length = lebek;
  for (int i = 0; i < n; ++i)
  {
    ll nowl, nowr;
    cin >> nowl >> nowr;

    if (nowr-nowl+1 >= length)
    {
      cout << length << "\n";
      return 0;
    }

    if (nowl/length != nowr/length) {
      opr(nowl % length + 1, length);
      opr(1, nowr % length + 1);
    } else {
      opr(nowl % length + 1, nowr % length + 1);
    }
  }

  answer();
  return 0;
}

Compilation message

strange_device.cpp: In function 'void answer()':
strange_device.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int i = 0; i < vec.size(); ++i)
      |                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 10 ms 1068 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 752 ms 16856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 981 ms 16772 KB Output is correct
3 Correct 1000 ms 17020 KB Output is correct
4 Correct 963 ms 16956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 981 ms 16772 KB Output is correct
3 Correct 1000 ms 17020 KB Output is correct
4 Correct 963 ms 16956 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1004 ms 16976 KB Output is correct
7 Correct 1010 ms 17040 KB Output is correct
8 Incorrect 1081 ms 16920 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 981 ms 16772 KB Output is correct
3 Correct 1000 ms 17020 KB Output is correct
4 Correct 963 ms 16956 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Incorrect 107 ms 2716 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 106 ms 2932 KB Output is correct
3 Incorrect 103 ms 2904 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 10 ms 1068 KB Output isn't correct
3 Halted 0 ms 0 KB -