結果

問題 No.60 魔法少女
ユーザー itezpaceitezpace
提出日時 2016-08-26 09:51:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,856 ms / 5,000 ms
コード長 1,089 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 66,304 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2024-04-25 16:10:53
合計ジャッジ時間 17,257 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2,123 ms
7,444 KB
testcase_05 AC 1,050 ms
8,304 KB
testcase_06 AC 2,834 ms
8,212 KB
testcase_07 AC 2,038 ms
8,044 KB
testcase_08 AC 1,118 ms
7,896 KB
testcase_09 AC 519 ms
7,484 KB
testcase_10 AC 2,519 ms
8,356 KB
testcase_11 AC 26 ms
7,568 KB
testcase_12 AC 674 ms
8,048 KB
testcase_13 AC 2,856 ms
8,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
int aa[1001][1001];
int main(){
  int n,k,x,y,hp,ax,ay,w,h,d;
  cin>>n>>k;
  vector<tuple<int,int,int>> v;
  int eax=0;
  int eix=1000;
  int eay=0;
  int eiy=1000;
  for(int i=0; i<n; ++i){
    cin>>x>>y>>hp;
    int a=x+500;
    int b=y+500;
    if(a>eax) eax=a;
    if(a<eix) eix=a;
    if(b>eay) eay=b;
    if(b<eiy) eiy=b;
    tuple<int,int,int> t=make_tuple(a,b,hp);
    v.push_back(t);
  }
  for(int i=0; i<k; ++i){
    cin>>ax>>ay>>w>>h>>d;
    int sx,ex,sy,ey;
    sx=ax+500;
    ex=ax+500+w;
    if(ex>1000) ex=1000;
    sy=ay+500;
    ey=ay+500+h;
    if(ey>1000) ey=1000;
    if(sx<eix) sx=eix;
    if(ex>eax) ex=eax;
    if(sy<eiy) sy=eiy;
    if(ey>eax) ey=eax;
    for(int j=sx; j<=ex; ++j){
      for(int k=sy; k<=ey; ++k){
        aa[j][k]+=d;
      }
    }
  }
  int z=0;
  for(int i=0; i<v.size(); ++i){
    tuple<int,int,int> t=v[i];
    int& tx=get<0>(t);
    int& ty=get<1>(t);
    int& thp=get<2>(t);
    thp-=aa[tx][ty];
    if(thp<0) thp=0;
    z+=thp;
  }
  cout<<z<<endl;
  return 0;
}
0