結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
assy1028
|
| 提出日時 | 2015-03-25 23:36:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 5,000 ms |
| コード長 | 1,615 bytes |
| コンパイル時間 | 1,457 ms |
| コンパイル使用メモリ | 158,604 KB |
| 実行使用メモリ | 25,212 KB |
| 最終ジャッジ日時 | 2024-06-29 00:59:07 |
| 合計ジャッジ時間 | 3,404 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘ll solve(int, int)’:
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d%d%lld", &_x, &_y, &hp[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d%d%d%d%lld", &ax, &ay, &w, &h, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:78:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
78 | scanf("%d%d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned int uint;
typedef unsigned long long ull;
struct pairhash {
public:
template<typename T, typename U>
size_t operator()(const pair<T, U> &x) const {
size_t seed = hash<T>()(x.first);
return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
};
const int inf = 1000000009;
const double eps = 1e-8;
ll board[1600][1600];
ll solve(int n, int k) {
int buf = 500, s = 1600;
int x[n], y[n];
ll hp[n];
for (int i = 0; i < n; i++) {
int _x, _y;
scanf("%d%d%lld", &_x, &_y, &hp[i]);
x[i] = _x + buf;
y[i] = _y + buf;
}
for (int i = 0; i < k; i++) {
int ax, ay, w, h;
ll d;
scanf("%d%d%d%d%lld", &ax, &ay, &w, &h, &d);
ax += buf;
ay += buf;
board[ay][ax] += d;
board[ay+h+1][ax] -= d;
board[ay][ax+w+1] -= d;
board[ay+h+1][ax+w+1] += d;
}
for (int i = 0; i < s; i++) {
for (int j = 1; j < s; j++) {
board[i][j] += board[i][j-1];
}
}
for (int i = 1; i < s; i++) {
for (int j = 0; j < s; j++) {
board[i][j] += board[i-1][j];
}
}
ll res = 0;
for (int i = 0; i < n; i++) {
res += max(0LL, hp[i] - board[y[i]][x[i]]);
}
return res;
}
int main() {
/*
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
*/
int n, k;
scanf("%d%d", &n, &k);
printf("%lld\n", solve(n, k));
}
assy1028