답안 #121338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121338 2019-06-26T11:15:43 Z LittleFlowers__ 이상한 기계 (APIO19_strange_device) C++14
35 / 100
765 ms 17036 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "A"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int n=in,a=in,b=in,sz=a/__gcd(a,b+1)*b;
    vector<ii> tmp;
    forinc(i,1,n){
        int l=in,r=in;
        if(r-l+1>sz) return cout<<sz,0;
        l=l%sz; r=r%sz;
        if(l<=r) tmp.pb({l,r});
        else tmp.pb({l,sz-1}),tmp.pb({0,r});
    }
    sort(all(tmp));
    int ret=0;
    forinc(i,0,tmp.size()-1){
        int j=i,hold=tmp[i].se;
        while(j<tmp.size() && tmp[j].fi<=hold){
            hold=max(hold,tmp[j].se);
            j++;
        }
        ret+=hold-tmp[i].fi+1;
        i=j-1;
    }
    cout<<ret;
}

Compilation message

strange_device.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
strange_device.cpp: In function 'int main()':
strange_device.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<tmp.size() && tmp[j].fi<=hold){
               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 9 ms 632 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 18 ms 356 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 252 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 9 ms 256 KB Output is correct
16 Correct 9 ms 732 KB Output is correct
17 Correct 78 ms 2540 KB Output is correct
18 Incorrect 2 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 455 ms 16976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 695 ms 16908 KB Output is correct
3 Correct 683 ms 16848 KB Output is correct
4 Correct 682 ms 16924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 695 ms 16908 KB Output is correct
3 Correct 683 ms 16848 KB Output is correct
4 Correct 682 ms 16924 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 693 ms 16816 KB Output is correct
7 Correct 697 ms 17036 KB Output is correct
8 Correct 682 ms 16848 KB Output is correct
9 Correct 732 ms 16816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 695 ms 16908 KB Output is correct
3 Correct 683 ms 16848 KB Output is correct
4 Correct 682 ms 16924 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 71 ms 2532 KB Output is correct
7 Correct 72 ms 2512 KB Output is correct
8 Correct 69 ms 2536 KB Output is correct
9 Correct 70 ms 2472 KB Output is correct
10 Correct 68 ms 2480 KB Output is correct
11 Correct 71 ms 2472 KB Output is correct
12 Correct 67 ms 2536 KB Output is correct
13 Correct 73 ms 2612 KB Output is correct
14 Correct 71 ms 2536 KB Output is correct
15 Correct 75 ms 2540 KB Output is correct
16 Correct 77 ms 2588 KB Output is correct
17 Correct 73 ms 2536 KB Output is correct
18 Correct 713 ms 16848 KB Output is correct
19 Correct 665 ms 16976 KB Output is correct
20 Correct 741 ms 17016 KB Output is correct
21 Correct 75 ms 2540 KB Output is correct
22 Correct 82 ms 2540 KB Output is correct
23 Correct 215 ms 8700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 89 ms 2540 KB Output is correct
3 Correct 74 ms 2488 KB Output is correct
4 Correct 765 ms 16896 KB Output is correct
5 Correct 73 ms 2540 KB Output is correct
6 Correct 74 ms 2492 KB Output is correct
7 Correct 74 ms 2476 KB Output is correct
8 Correct 74 ms 2508 KB Output is correct
9 Correct 67 ms 2540 KB Output is correct
10 Correct 73 ms 2476 KB Output is correct
11 Correct 74 ms 2540 KB Output is correct
12 Correct 66 ms 2508 KB Output is correct
13 Correct 74 ms 2540 KB Output is correct
14 Correct 738 ms 16864 KB Output is correct
15 Correct 79 ms 2512 KB Output is correct
16 Correct 709 ms 16884 KB Output is correct
17 Correct 683 ms 16876 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 9 ms 632 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 18 ms 356 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 252 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 9 ms 256 KB Output is correct
16 Correct 9 ms 732 KB Output is correct
17 Correct 78 ms 2540 KB Output is correct
18 Incorrect 2 ms 256 KB Output isn't correct