Submission #1506181


Source Code Expand

Copy
#include <iostream>
using namespace std;

// a-b, c-d
int solve(int a, int b, int c, int d) {
  if (c < a) { swap(a,c); swap(b,d); }
  // a <= c d
  // abcd, acbd, acdb

  if (b <= c) return 0; // abcd
  if (d <= b) return d-c; // acdb
  return b-c; // acbd
}

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = solve(a,b,c,d);
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task B - Two Switches
User naoya_t
Language C++14 (GCC 5.4.1)
Score 200
Code Size 398 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 200 / 200 sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_1.txt 1 ms 256 KB
subtask_1_2.txt 1 ms 256 KB
subtask_1_3.txt 1 ms 256 KB
subtask_1_4.txt 1 ms 256 KB
subtask_1_5.txt 1 ms 256 KB
subtask_1_6.txt 1 ms 256 KB
subtask_1_7.txt 1 ms 256 KB
subtask_1_8.txt 1 ms 256 KB
subtask_1_9.txt 1 ms 256 KB