提出 #293299


ソースコード 拡げる

#define _CRT_SECURE_NO_WARNINGS 
#include <iostream> 
#include <sstream> 
#include <algorithm> 
#include <string> 
#include <queue> 
#include <stack> 
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <utility> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <functional> 
using namespace std;
const int MAX_N = 100;

int P[MAX_N] = {};

void solve(int a, int b, int s, int t) {
	if (a <= s) {
		if (b <= s) {
			cout << t - s << endl;
		}
		else if (b <= t) {
			cout << t - b << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else if (a <= t) {
		if (b <= t) {
			cout << t - s - (b - a) << endl;
		}
		else {
			cout << a - s << endl;
		}
	}
	else {
		cout << t - s << endl;
	}
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int a, b, s, t;
		cin >> a >> b >> s >> t;
		solve(a * 100, b * 100, s * 100, t * 100);
	}

	return 0;
}

提出情報

提出日時
問題 D - 定期券
ユーザ osakanasan
言語 C++ (G++ 4.6.4)
得点 100
コード長 1012 Byte
結果 AC
実行時間 355 ms
メモリ 932 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 2
AC × 14
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All large_01.txt, large_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, small_01.txt, small_02.txt
ケース名 結果 実行時間 メモリ
large_01.txt AC 176 ms 928 KiB
large_02.txt AC 326 ms 928 KiB
random_01.txt AC 339 ms 860 KiB
random_02.txt AC 329 ms 800 KiB
random_03.txt AC 344 ms 796 KiB
random_04.txt AC 336 ms 932 KiB
random_05.txt AC 338 ms 804 KiB
random_06.txt AC 321 ms 932 KiB
random_07.txt AC 355 ms 924 KiB
random_08.txt AC 332 ms 800 KiB
random_09.txt AC 346 ms 924 KiB
random_10.txt AC 354 ms 788 KiB
sample_01.txt AC 22 ms 920 KiB
sample_02.txt AC 23 ms 928 KiB
small_01.txt AC 26 ms 760 KiB
small_02.txt AC 24 ms 800 KiB