Submission #56879

# Submission time Handle Problem Language Result Execution time Memory
56879 2018-07-13T04:16:49 Z 윤교준(#1636) None (JOI15_walls) C++11
10 / 100
3000 ms 17820 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 200005;
const int MAXQ = 200005;

int A[MAXN], B[MAXN];
int C[MAXQ];

ll Ans[MAXN];
int N, Q;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> Q;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
	for(int i = 1; i <= Q; i++) cin >> C[i];

	for(int i = 1, x, l; i <= N; i++) {
		l = B[i]-A[i]+1; x = A[i];

		for(int qi = 1, y; qi <= Q; qi++) {
			y = C[qi];

			if(x <= y && y < x+l) continue;
			else if(y < x) {
				Ans[i] += x-y;
				x = y;
			} else {
				Ans[i] += y-x-l+1;
				x = y-l+1;
			}
		}
	}

	for(int i = 1; i <= N; i++) printf("%lld\n", Ans[i]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 43 ms 3152 KB Output is correct
3 Correct 41 ms 5144 KB Output is correct
4 Correct 39 ms 7220 KB Output is correct
5 Correct 37 ms 9256 KB Output is correct
6 Correct 52 ms 11164 KB Output is correct
7 Correct 37 ms 12972 KB Output is correct
8 Correct 55 ms 14884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2457 ms 15444 KB Output is correct
2 Execution timed out 3041 ms 17820 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 43 ms 3152 KB Output is correct
3 Correct 41 ms 5144 KB Output is correct
4 Correct 39 ms 7220 KB Output is correct
5 Correct 37 ms 9256 KB Output is correct
6 Correct 52 ms 11164 KB Output is correct
7 Correct 37 ms 12972 KB Output is correct
8 Correct 55 ms 14884 KB Output is correct
9 Correct 2457 ms 15444 KB Output is correct
10 Execution timed out 3041 ms 17820 KB Time limit exceeded
11 Halted 0 ms 0 KB -