제출 #1294191

#제출 시각아이디문제언어결과실행 시간메모리
1294191avighnaPairs (IOI07_pairs)C++20
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int b; cin >> b; if (b == 1) { int n, d; cin >> n >> d; vector<int> a(n); for (int &i : a) { cin >> i; } sort(a.begin(), a.end()); int64_t ans = 0; for (int i = 0, ptr1 = 0, ptr2 = 0; i < n; ++i) { while (ptr1 < n && a[i] - a[ptr1] > d) { ptr1++; } while (ptr2 < n && a[ptr2] - a[i] <= d) { ptr2++; } ans += ptr2 - ptr1 - 1; } cout << ans << '\n'; return 0; } }

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

pairs.cpp: In function 'int main()':
pairs.cpp:15:5: error: 'vector' was not declared in this scope
   15 |     vector<int> a(n);
      |     ^~~~~~
pairs.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include <iostream>
  +++ |+#include <vector>
    3 | 
pairs.cpp:15:12: error: expected primary-expression before 'int'
   15 |     vector<int> a(n);
      |            ^~~
pairs.cpp:16:19: error: 'a' was not declared in this scope
   16 |     for (int &i : a) {
      |                   ^
pairs.cpp:19:10: error: 'a' was not declared in this scope
   19 |     sort(a.begin(), a.end());
      |          ^