結果
問題 | No.2261 Coffee |
ユーザー |
|
提出日時 | 2023-04-07 22:23:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 284 ms / 2,000 ms |
コード長 | 1,392 bytes |
コンパイル時間 | 874 ms |
コンパイル使用メモリ | 88,564 KB |
最終ジャッジ日時 | 2025-02-12 01:46:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:41:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | for (i=0; i<n; i++) scanf("%lld %lld %lld %lld %lld", &as[i], &bs[i], &cs[i], &ds[i], &es[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<string.h>#include<stdlib.h>#include <map>#include <vector>#include <queue>#include <deque>#include <set>#include <stack>#include <algorithm>#include <array>#include <unordered_set>#include <unordered_map>#include <string>using namespace std;bool rcmp(int a, int b) { return a>b; }typedef long long LL;class mypcmp {public:bool operator()(const int& a, const int& b) {return a<b;}};LL as[100004];LL bs[100004];LL cs[100004];LL ds[100004];LL es[100004];LL rs[100004];typedef struct { LL v; int i; } SNode;SNode sg[100004];bool mycmp(const SNode& a, const SNode& b) { return a.v<b.v; }int main() {int n, i, k;LL v, d;scanf("%d", &n);for (i=0; i<n; i++) scanf("%lld %lld %lld %lld %lld", &as[i], &bs[i], &cs[i], &ds[i], &es[i]);for (i=0; i<n; i++) rs[i]=0;for (k=0; k<16; k++) {for (i=0; i<n; i++) {v=as[i]; if (k&1) v-=bs[i]; else v+=bs[i];if (k&2) v-=cs[i]; else v+=cs[i];if (k&4) v-=ds[i]; else v+=ds[i];if (k&8) v-=es[i]; else v+=es[i];sg[i].v=v; sg[i].i=i;}sort(sg, sg+n, mycmp);for (i=0; i<n; i++) {d=max(sg[i].v-sg[0].v, sg[n-1].v-sg[i].v);rs[sg[i].i]=max(d, rs[sg[i].i]);}}for (i=0; i<n; i++) printf("%lld\n", rs[i]);return 0;}