답안 #782599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782599 2023-07-14T06:19:49 Z kebine 이상한 기계 (APIO19_strange_device) C++17
65 / 100
1333 ms 34536 KB
#include <bits/stdc++.h>
#define LL long long 
LL INF =1e18+5LL; 
using namespace std;
int main()
{
  LL n,a,b;
  cin>>n>>a>>b;
  LL t = (a/__gcd(b+1,a));

  vector<pair<LL,LL>>v;
  __int128_t x=(__int128_t)b*t;
  if(x>INF)t=INF;
  else t=(LL)x;

//  printf("t=%lld\n",t);
bool jawab=false;
  for(LL a=1;a<=n;a++)
  {
    LL l,r;
    cin>>l>>r;
    LL temp=l,temp2=r;
  /*  if(jawab)continue;
    if(l-r+1>=t)
    {
      printf("%lld\n",t);
      jawab=1;
      continue;
  }*/
  
    l%=t ,r%=t;
    if(l==r)
    {
      if(temp==temp2)
      {
        v.push_back(make_pair(l,0));
        v.push_back(make_pair(r,1));
      }
      else
      {
        v.push_back(make_pair(0,0));
        v.push_back(make_pair(t-1,1));
       } 
    }
    else if(l>r)
    {
  //    printf("->%lld,%lld\n-> 0 %lld\n",l,t-1,r);
    //  v.push_back(make_pair(l,t-1));
      v.push_back(make_pair(l,0));
      v.push_back(make_pair(t-1,1));
    //  v.push_back(make_pair(0,r));
      v.push_back(make_pair(0,0));
      v.push_back(make_pair(r,1));
    }
    else
    {
      v.push_back(make_pair(l,0));
        v.push_back(make_pair(r,1));
     } 

  }
  sort(v.begin(),v.end());
  LL kanan=0,tot=0,kiri=0,cnt=0;
  for(pair<LL,LL>x:v)
  {
    if(x.second==0)
    {
      cnt++;
      if(cnt==1)kiri=x.first;
    }
    else
    {
      cnt--;
      if(cnt==0)tot+=(x.first-kiri+1);
    }
  }
  cout<<tot<<endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:17:6: warning: unused variable 'jawab' [-Wunused-variable]
   17 | bool jawab=false;
      |      ^~~~~
strange_device.cpp:63:6: warning: unused variable 'kanan' [-Wunused-variable]
   63 |   LL kanan=0,tot=0,kiri=0,cnt=0;
      |      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 11 ms 848 KB Output is correct
3 Correct 13 ms 952 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 11 ms 904 KB Output is correct
17 Correct 118 ms 4528 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 744 ms 33180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1071 ms 33180 KB Output is correct
3 Correct 1120 ms 33268 KB Output is correct
4 Correct 1059 ms 33356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1071 ms 33180 KB Output is correct
3 Correct 1120 ms 33268 KB Output is correct
4 Correct 1059 ms 33356 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1083 ms 33236 KB Output is correct
7 Correct 1084 ms 33296 KB Output is correct
8 Correct 1120 ms 33248 KB Output is correct
9 Correct 1230 ms 33816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1071 ms 33180 KB Output is correct
3 Correct 1120 ms 33268 KB Output is correct
4 Correct 1059 ms 33356 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 137 ms 4908 KB Output is correct
7 Correct 134 ms 4844 KB Output is correct
8 Correct 109 ms 4868 KB Output is correct
9 Correct 129 ms 4836 KB Output is correct
10 Correct 125 ms 4808 KB Output is correct
11 Correct 118 ms 4840 KB Output is correct
12 Correct 112 ms 4824 KB Output is correct
13 Correct 126 ms 4896 KB Output is correct
14 Correct 122 ms 4880 KB Output is correct
15 Correct 122 ms 4888 KB Output is correct
16 Correct 124 ms 4880 KB Output is correct
17 Correct 128 ms 4908 KB Output is correct
18 Correct 1212 ms 33840 KB Output is correct
19 Correct 1105 ms 33880 KB Output is correct
20 Correct 1218 ms 34316 KB Output is correct
21 Correct 138 ms 5188 KB Output is correct
22 Correct 121 ms 5304 KB Output is correct
23 Correct 350 ms 18152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 124 ms 5204 KB Output is correct
3 Correct 118 ms 5068 KB Output is correct
4 Correct 1333 ms 34208 KB Output is correct
5 Correct 165 ms 5188 KB Output is correct
6 Correct 116 ms 5280 KB Output is correct
7 Correct 121 ms 5280 KB Output is correct
8 Correct 127 ms 5300 KB Output is correct
9 Correct 110 ms 5048 KB Output is correct
10 Correct 122 ms 5116 KB Output is correct
11 Correct 123 ms 5128 KB Output is correct
12 Correct 110 ms 5188 KB Output is correct
13 Correct 113 ms 5192 KB Output is correct
14 Correct 1272 ms 34156 KB Output is correct
15 Correct 115 ms 5196 KB Output is correct
16 Correct 1058 ms 33764 KB Output is correct
17 Correct 1109 ms 34536 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 11 ms 848 KB Output is correct
3 Correct 13 ms 952 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 11 ms 904 KB Output is correct
17 Correct 118 ms 4528 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -