답안 #1032751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032751 2024-07-24T07:57:48 Z Gangsta 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 524288 KB
#include "bits/stdc++.h"
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sz size()

const int N = 2e5 + 1;

using namespace std;

ll n, a, b, ans = 0;

set <pii> s;

vector <pii> v;

int main(){
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
    	ll x, y;
    	cin >> x >> y;
    	if(b == 1){
    		if(y - x + 1 >= a) return cout << a,0;
    		ll san = (2*x) % a, san1 = (2*y) % a;
    		if(san <= san1){
    			v.pb({san,0});
    			v.pb({san1,1});
    		} 
    		else{
    			v.pb({0,0});
    			v.pb({san1,1});
    			v.pb({san,0});
    			v.pb({a-1,1});
    		}
    	}
    	else{
	    	for(ll j = x; j <= y; j++){
	    		ll san = j + j/b;
	    		san %= a;
	    		int san1 = j % b;
	    		s.insert({san,san1});
	    	}
	    	ans = (int)s.sz;
	    }
    }
    if(b == 1){
    	sort(v.begin(), v.end());
    	ll ac = 0, bas = 1e18;
		for(auto i: v){
			if(i.ss == 0){
				ac++;
				bas = min(bas,i.ff);
			}
			else{
				ac--;
				if(ac == 0){
					ans += i.ff - bas + 1;
					bas = 1e18;
				}
			}
		}
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 34 ms 12676 KB Output is correct
3 Correct 46 ms 18260 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 428 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 1112 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1567 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 94 ms 32328 KB Output is correct
3 Correct 102 ms 32196 KB Output is correct
4 Correct 75 ms 30720 KB Output is correct
5 Execution timed out 5061 ms 62480 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 963 ms 69124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 963 ms 69124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 963 ms 69124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 953 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 34 ms 12676 KB Output is correct
3 Correct 46 ms 18260 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 428 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 1112 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -