제출 #741456

#제출 시각아이디문제언어결과실행 시간메모리
741456abczz이상한 기계 (APIO19_strange_device)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <array>
#define ll long long

using namespace std;

ll n, a, b, x, y, l, r, f;
vector<array<ll, 2>> A;
int main() {
  cin >> n >> a >> b;
  for (int i=0; i<n; ++i) {
    cin >> x >> y;
    l = y-x;
    x %= (a*b);
    if (x+l >= a*b) {
      l -= a*b-x;
      l = min(l, a*b-1);
      A.push_back({x, a*b-1});
      A.push_back({0, l});
    }
    else A.push_back({x, x+l});
  }
  sort(A.begin(), A.end());
  l = r = -1e9;
  ++l;
  for (auto [u, v] : A) {
    if (r+1 < u) {
      //cout << l << " " << r << endl;
      f += r-l+1;
      l = u, r = v;
    }
    else r = max(r, v);
  }
  //cout << l << " " << r << endl;
  f += (r-l)+1;
  cout << f << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
strange_device.cpp:24:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   24 |   sort(A.begin(), A.end());
      |   ^~~~
      |   qsort
strange_device.cpp:27:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |   for (auto [u, v] : A) {
      |             ^