답안 #443831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443831 2021-07-12T07:43:47 Z prvocislo 이상한 기계 (APIO19_strange_device) C++17
10 / 100
781 ms 68912 KB
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
ll mod, a, b;
void calculate_mod()
{
    if (((ld)a) * ((ld)b) > 2e18) mod = 2e18;
    else mod = a*b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cin >> n >> a >> b;
    calculate_mod();
    vector<pair<ll, int> > v;
    for (int i = 0; i < n; i++)
    {
        ll l, r;
        cin >> l >> r;
        if (r - l + 1 >= mod)
        {
            v.push_back({0, 1});
            v.push_back({mod, -1});
        }
        else
        {
            l %= mod, r %= mod;
            if (l <= r) 
            {
                v.push_back({l, 1}), v.push_back({r+1, -1});
            }
            else
            {
                v.push_back({0, 1}), v.push_back({r+1, -1});
                v.push_back({l, 1}), v.push_back({mod, -1});
            } 
        }
    }
    //cout << "===========\n" << mod << "\n";
    sort(v.begin(), v.end());
    ll ans = 0; int sum = 0;
    for (int i = 0; i < v.size() - 1; i++)
    {
        //cout << v[i].first << " " << v[i].second << "\n";
        sum += v[i].second;
        if (sum) ans += v[i+1].first-v[i].first;
    }
    cout << ans << "\n";
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < v.size() - 1; i++)
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 6 ms 1328 KB Output is correct
3 Correct 7 ms 1232 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 432 ms 56940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 621 ms 68800 KB Output is correct
3 Incorrect 589 ms 68780 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 621 ms 68800 KB Output is correct
3 Incorrect 589 ms 68780 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 621 ms 68800 KB Output is correct
3 Incorrect 589 ms 68780 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 68 ms 7264 KB Output is correct
3 Correct 69 ms 7216 KB Output is correct
4 Correct 781 ms 68788 KB Output is correct
5 Correct 67 ms 7236 KB Output is correct
6 Correct 69 ms 7204 KB Output is correct
7 Correct 68 ms 7276 KB Output is correct
8 Correct 72 ms 7280 KB Output is correct
9 Correct 66 ms 7220 KB Output is correct
10 Correct 72 ms 7216 KB Output is correct
11 Correct 70 ms 7244 KB Output is correct
12 Correct 60 ms 7276 KB Output is correct
13 Correct 69 ms 7236 KB Output is correct
14 Correct 738 ms 68912 KB Output is correct
15 Incorrect 74 ms 7220 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 6 ms 1328 KB Output is correct
3 Correct 7 ms 1232 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -