Submission #1129973

#TimeUsernameProblemLanguageResultExecution timeMemory
1129973Username_taken12Remittance (JOI19_remittance)Java
0 / 100
54 ms10564 KiB
import java.io.*; import java.util.StringTokenizer; public class remittance { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int N = Integer.parseInt(r.readLine()); int[] val = new int[N]; for(int i=0; i<N; i++){ StringTokenizer st = new StringTokenizer(r.readLine()); val[i]=Integer.parseInt(st.nextToken())-Integer.parseInt(st.nextToken()); } int las=N-1; for(int i=0; i<N; i=(i+1)%N){ if(val[i]<=0){ if(las==i) break; continue; } int t = (val[i]+1)/2; val[i]-=2*t; val[(i+1)%N]+=t; las=i; } boolean w = true; for(int i=0; i<N; i++) if(val[i]!=0) w=false; if(w) pw.println("Yes"); else pw.println("No"); pw.close(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...