Submission #979296

# Submission time Handle Problem Language Result Execution time Memory
979296 2024-05-10T13:32:31 Z nnin Strange Device (APIO19_strange_device) C++17
10 / 100
388 ms 53932 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define f first
#define s second
#define ll long long

int n;
ll A, B;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>A>>B;
    vector<pii> v;
    bool all = 0;
    for(int i=0;i<n;i++) {
        ll l, r;
        cin>>l>>r;
        if(all) continue;
        ll x = l/A;
        x /= B;
        ll y = r/A;
        y /= B;
        if(x==0 && y==0) {
            v.push_back({l, r});
        } else if(r-l+1>=A*B) {
            all = 1;
        } else if(x==y) {
            v.push_back({l%(A*B), r%(A*B)});
        } else {
            v.push_back({l%(A*B), (A*B)-1});
            v.push_back({0, r%(A*B)});
        }
    }
    if(all) {
        cout<<A*B;
        return 0;
    }
    sort(v.begin(), v.end());
    ll ct = 0, last = -1;
    for(int i=0;i<v.size();i++) {
        if(last>v[i].s) continue;
        if(last<v[i].f) last = v[i].f-1;
        ct += v[i].s-last;
        last = v[i].s;
    }
    cout<<ct;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:42:18: 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]
   42 |     for(int i=0;i<v.size();i++) {
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 5 ms 1108 KB Output is correct
3 Correct 4 ms 1196 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 233 ms 41292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 351 ms 53492 KB Output is correct
3 Incorrect 329 ms 53404 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 351 ms 53492 KB Output is correct
3 Incorrect 329 ms 53404 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 351 ms 53492 KB Output is correct
3 Incorrect 329 ms 53404 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 38 ms 5836 KB Output is correct
3 Correct 40 ms 5992 KB Output is correct
4 Correct 388 ms 53932 KB Output is correct
5 Correct 34 ms 5832 KB Output is correct
6 Correct 50 ms 5836 KB Output is correct
7 Correct 36 ms 5836 KB Output is correct
8 Correct 36 ms 5852 KB Output is correct
9 Correct 35 ms 5832 KB Output is correct
10 Correct 42 ms 5808 KB Output is correct
11 Correct 35 ms 5764 KB Output is correct
12 Correct 31 ms 5832 KB Output is correct
13 Correct 36 ms 5892 KB Output is correct
14 Correct 365 ms 53184 KB Output is correct
15 Incorrect 39 ms 5812 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 5 ms 1108 KB Output is correct
3 Correct 4 ms 1196 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -