제출 #981397

#제출 시각아이디문제언어결과실행 시간메모리
981397Amaarsaa이상한 기계 (APIO19_strange_device)C++14
40 / 100
361 ms18936 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j; cin >> n >> a >> b; s = __gcd(b + 1, a); s = a / s; p = 1e18/s; if ( p < s) { s= 0; for (i = 1; i <= n; i ++) { cin >> x >> y; s += (y -x + 1); } cout << s<< endl; return 0; } s = s * b; ans = 0; map < ll, ll > A; vector < pair <ll,ll > > v; for (i = 1; i <= n; i ++) { cin >> x >> y; if ( x / s == y / s) { v.push_back({x%s, y%s}); } else { if ( x / s + 1 == y / s) { v.push_back({x%s, s - 1}); v.push_back({0, y%s}); } else { cout << s << endl; return 0; } } } sort(v.begin(), v.end()); ll mx = -1; for (i = 0; i < v.size(); i ++) { if ( v[i].first <= mx) { ans += max(0ll, v[i].second - mx); } else ans += (v[i].second - v[i].first + 1); mx =max(mx, v[i].second); } cout << ans << endl; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:48:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  for (i = 0; i < v.size(); i ++) {
      |              ~~^~~~~~~~~~
strange_device.cpp:10:5: warning: unused variable 't' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |     ^
strange_device.cpp:10:11: warning: unused variable 'm' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |           ^
strange_device.cpp:10:18: warning: unused variable 'l' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                  ^
strange_device.cpp:10:30: warning: unused variable 'lo' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                              ^~
strange_device.cpp:10:34: warning: unused variable 'hi' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                  ^~
strange_device.cpp:10:38: warning: unused variable 'mid' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                      ^~~
strange_device.cpp:10:43: warning: unused variable 'sum' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                           ^~~
strange_device.cpp:10:54: warning: unused variable 'r' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                                      ^
strange_device.cpp:10:63: warning: unused variable 'j' [-Wunused-variable]
   10 |  ll t, n, m, ans,l, a, b, s, lo, hi, mid, sum, x, y, r, p, i, j;
      |                                                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...