提出 #4101681


ソースコード 拡げる

#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int main() {
  int n; scanf("%d", &n);
  ll a[n], b[n];
  pli d[n];
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", a+i, b+i);
    d[i] = make_pair(a[i]-b[i], i);
  }
  ll ans=0;
  sort(d,d+n);
  for (int i = 0; i < n; ++i) {
    int idx = d[i].second;
    if (i%2==0) {
      ans+=a[idx];
    } else {
      ans-=b[idx];
    }
  }
  printf("%lld\n", ans);
  return 0;
}

提出情報

提出日時
問題 C - Different Strokes
ユーザ mirac
言語 C++14 (GCC 5.4.1)
得点 0
コード長 621 Byte
結果 WA
実行時間 34 ms
メモリ 3328 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int n; scanf("%d", &n);
                         ^
./Main.cpp:18:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", a+i, b+i);
                                ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 3
AC × 6
WA × 7
セット名 テストケース
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
ケース名 結果 実行時間 メモリ
a01 AC 1 ms 128 KiB
a02 AC 1 ms 128 KiB
a03 AC 1 ms 128 KiB
b04 AC 1 ms 128 KiB
b05 AC 21 ms 3328 KiB
b06 AC 20 ms 3328 KiB
b07 WA 34 ms 3328 KiB
b08 WA 28 ms 3328 KiB
b09 WA 28 ms 3328 KiB
b10 WA 28 ms 3328 KiB
b11 WA 28 ms 3328 KiB
b12 WA 28 ms 3328 KiB
b13 WA 29 ms 3328 KiB