結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2018-06-06 00:20:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 32,640 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 10:11:01 |
合計ジャッジ時間 | 1,018 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <stdio.h> #include <stdlib.h> int func(const void *a, const void *b){ return *(int *)a - *(int *)b; } int main(){ long long int N, i; long long int a[1000], b[1000], width[1000]; long long int cnt = 0, sub, divi; scanf("%lld\n", &N); for(i = 0; i < N; i++){ scanf("%lld %lld\n", &a[i], &b[i]); width[i] = a[i] + 4*b[i]; } qsort(width, N, sizeof(long long int), func); /* for(i = 0; i < N; i++){ printf("%lld\n", width[i]); } */ for(i = 0; i < N; i++){ sub = width[N - 1] - width[i]; //printf("max %lld\n", width[N - 1]); if(sub > 0){ divi = sub/2; if(sub%2 == 0){ cnt += divi; }else{ printf("-1\n"); return 0; } } } printf("%lld\n", cnt); return 0; }