結果
問題 | No.60 魔法少女 |
ユーザー | fumiphys |
提出日時 | 2019-08-24 17:19:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 99 ms / 5,000 ms |
コード長 | 3,823 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 170,016 KB |
実行使用メモリ | 35,812 KB |
最終ジャッジ日時 | 2024-10-14 12:59:31 |
合計ジャッジ時間 | 4,030 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
34,904 KB |
testcase_01 | AC | 22 ms
34,720 KB |
testcase_02 | AC | 21 ms
34,808 KB |
testcase_03 | AC | 21 ms
34,720 KB |
testcase_04 | AC | 65 ms
35,076 KB |
testcase_05 | AC | 64 ms
35,712 KB |
testcase_06 | AC | 97 ms
35,800 KB |
testcase_07 | AC | 76 ms
35,388 KB |
testcase_08 | AC | 57 ms
35,368 KB |
testcase_09 | AC | 37 ms
34,964 KB |
testcase_10 | AC | 93 ms
35,784 KB |
testcase_11 | AC | 28 ms
35,016 KB |
testcase_12 | AC | 53 ms
35,288 KB |
testcase_13 | AC | 99 ms
35,812 KB |
ソースコード
// includes #include <bits/stdc++.h> // macros #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--) #define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr) #define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr) #define vrep(v, i) for(int i = 0; i < (v).size(); i++) #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define FI first #define SE second #define bit(n) (1LL<<(n)) #define INT(n) int n; cin >> n; #define LL(n) ll n; cin >> n; #define DOUBLE(n) double n; cin >> n; using namespace std; template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;} template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;} template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;} template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;} template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;} template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;} template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;} template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;} template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;} template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;} template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;} // types using ll = long long int; using P = pair<int, int>; using Pli = pair<ll, int>; using Pil = pair<int, ll>; using Pll = pair<ll, ll>; using Pdd = pair<double, double>; using cd = complex<double>; // constants const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; const int mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; // solve ll s[2010][2010]; int main(int argc, char const* argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); INT(n); INT(k); vector<int> x(n), y(n), hp(n); rep(i, n)cin >> x[i] >> y[i] >> hp[i], x[i] += 500, y[i] += 500; rep(i, k){ INT(ax); INT(ay); INT(w); INT(h); LL(d); ax += 500, ay += 500; s[ax][ay] += d; s[ax+w+1][ay] -= d; s[ax][ay+h+1] -= d; s[ax+w+1][ay+h+1] += d; } rep(i, 2001){ rep(j, 2001){ if(i > 0)s[i][j] += s[i-1][j]; } } rep(i, 2001){ rep(j, 2001){ if(j > 0)s[i][j] += s[i][j-1]; } } ll res = 0; rep(i, n){ res += max(0LL, hp[i] - s[x[i]][y[i]]); } cout << res << endl; return 0; }