Submission #317735

# Submission time Handle Problem Language Result Execution time Memory
317735 2020-10-30T08:57:26 Z tjdgus4384 Strange Device (APIO19_strange_device) C++14
0 / 100
61 ms 6768 KB
#include<bits/stdc++.h>
using namespace std;
long long n, A, B, l[100001], r[100001], S;
vector<pair<int, int> > v;

int main(){
    scanf("%lld %lld %lld", &n, &A, &B);
    for(int i = 0;i < n;i++){
        scanf("%lld %lld", &l[i], &r[i]);
        S += r[i] - l[i] + 1;
    }
    if(((B+1)%A) == 0){
        printf("1");
        return 0;
    }
    long long t = A*B;
    for(int i = 0;i < n;i++){
        l[i] %= t;
        r[i] %= t;
        if(r[i] < l[i]){
            v.push_back({l[i], t-1});
            v.push_back({0, r[i]});
        }
        else v.push_back({l[i], r[i]});
    }
    sort(v.begin(), v.end());
    long long s = v[0].first, e = v[0].second, ans = 0;
    for(int i = 1;i < v.size();i++){
        if(v[i].first <= e) e = v[i].second;
        else{
            ans += (e-s+1);
            s = v[i].first;
            e = v[i].second;
        }
    }
    ans += e - s + 1;
    printf("%lld", ans);
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 1;i < v.size();i++){
      |                   ~~^~~~~~~~~~
strange_device.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%lld %lld %lld", &n, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |         scanf("%lld %lld", &l[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 6 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Execution timed out 47 ms 5884 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Execution timed out 47 ms 5884 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Execution timed out 47 ms 5884 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 61 ms 6768 KB Output is correct
3 Incorrect 55 ms 6768 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 6 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -