https://paiza.jp/learning/long-table
Il s'agit de savoir comment gérer la limite.
package jp.mirageworld.paiza_learning;
import java.io.InputStream;
import java.util.Scanner;
class UnagiNew {
public static void main(String[] args) {
System.out.println(exec(System.in));
}
public static int exec(InputStream is) {
try (Scanner sc = new Scanner(is);) {
//nombre de places
int n = sc.nextInt();
boolean[] bools = new boolean[n];
//Nombre de groupes
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
//Nombre de personnes
int a = sc.nextInt();
//Position de départ
int b = sc.nextInt();
//vérifier
boolean check = false;
for (int j = b; j < a + b; j++)
if (bools[j % bools.length] && (check = true))
break;
if (check)
continue;
for (int j = b; j < a + b; j++)
bools[j % bools.length] = true;
}
int ret = 0;
for (boolean b : bools)
if (b)
ret++;
return ret;
}
}
}
Relation: https://qiita.com/krppppp/items/a75205c9dcb4165ca2b4