結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2018-06-06 00:17:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 32,640 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 10:10:53 |
合計ジャッジ時間 | 1,121 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 15 RE * 6 |
ソースコード
#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{ return -1; } } } printf("%lld\n", cnt); return 0; }