結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2,117 ms
7,568 KB
testcase_05 AC 1,044 ms
8,224 KB
testcase_06 AC 2,816 ms
8,340 KB
testcase_07 AC 2,010 ms
7,872 KB
testcase_08 AC 1,084 ms
7,768 KB
testcase_09 AC 510 ms
7,572 KB
testcase_10 AC 2,462 ms
8,220 KB
testcase_11 AC 26 ms
7,444 KB
testcase_12 AC 648 ms
7,900 KB
testcase_13 AC 2,805 ms
8,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int arr[1001][1001];

int main(){
  int n,k,x,y,hp,ax,ay,w,h,d;
  cin>>n>>k;
  vector<tuple<int,int,int>> v;
  for(int i=0; i<n; ++i){
    cin>>x>>y>>hp;
    tuple<int,int,int> t=make_tuple(x,y,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;
    for(int j=sx; j<=ex; ++j){
      for(int k=sy; k<=ey; ++k){
        arr[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);
    int tx2=tx+500;
    int ty2=ty+500;
    int thp2=thp;
    thp2-=arr[tx2][ty2];
    if(thp2<0) thp2=0;
    z+=thp2;
  }
  cout<<z<<endl;
  return 0;
}
0