結果

問題 No.60 魔法少女
ユーザー itezpaceitezpace
提出日時 2016-08-26 09:11:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,499 ms / 5,000 ms
コード長 978 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 66,464 KB
実行使用メモリ 8,984 KB
最終ジャッジ日時 2024-04-25 15:49:22
合計ジャッジ時間 21,040 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,140 KB
testcase_01 AC 4 ms
7,224 KB
testcase_02 AC 3 ms
7,352 KB
testcase_03 AC 3 ms
7,208 KB
testcase_04 AC 2,577 ms
7,540 KB
testcase_05 AC 1,260 ms
8,732 KB
testcase_06 AC 3,499 ms
8,732 KB
testcase_07 AC 2,469 ms
8,860 KB
testcase_08 AC 1,335 ms
8,024 KB
testcase_09 AC 618 ms
7,632 KB
testcase_10 AC 3,025 ms
8,724 KB
testcase_11 AC 28 ms
7,644 KB
testcase_12 AC 780 ms
8,984 KB
testcase_13 AC 3,432 ms
8,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int arr[1001][1001];

int main(){
  for(int i=0; i<1001; ++i){
    for(int j=0; j<1001; ++j){
      arr[i][j]=0;
    }
  }
  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