Submission #782446

# Submission time Handle Problem Language Result Execution time Memory
782446 2023-07-14T01:48:55 Z makanhulia Strange Device (APIO19_strange_device) C++17
5 / 100
437 ms 33212 KB
#include <bits/stdc++.h>
#define LL long long 
using namespace std;
int main()
{
  LL n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  LL t=b*(a/__gcd(b+1,a));
  vector<pair<LL,LL>>v;
  for(LL a=1;a<=n;a++)
  {
    LL l,r;
    scanf("%lld %lld",&l,&r);
    l%=t ,r%=t;
    if(l>=r)
    {
      v.push_back(make_pair(l,t-1));
      v.push_back(make_pair(0,r));
    }
    else v.push_back(make_pair(l,r));
  }
  sort(v.begin(),v.end());
  LL kanan=0,tot=0,kiri=0;
  for(pair<LL,LL>x:v)
  {
    if(x.second>=kanan && (x.first<=kanan ))
    {
      kanan=x.second;
    }
    else if(kanan<x.first)
    {
      tot+=(kanan-kiri+1);
      kiri=x.first,kanan=x.second;
    }
  }
  tot+=(kanan-kiri+1);
  cout<<tot<<endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:7:8: 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:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld %lld",&l,&r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 5 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 225 ms 16776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 437 ms 33212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 437 ms 33212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 437 ms 33212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 36 ms 2416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 5 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -