結果

問題 No.60 魔法少女
ユーザー latte0119latte0119
提出日時 2016-02-26 21:35:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 1,243 bytes
コンパイル時間 1,263 ms
コンパイル使用メモリ 160,172 KB
実行使用メモリ 8,988 KB
最終ジャッジ日時 2023-10-23 20:23:19
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,600 KB
testcase_01 AC 5 ms
8,600 KB
testcase_02 AC 5 ms
8,600 KB
testcase_03 AC 5 ms
8,600 KB
testcase_04 AC 41 ms
8,664 KB
testcase_05 AC 44 ms
8,968 KB
testcase_06 AC 70 ms
8,964 KB
testcase_07 AC 53 ms
8,868 KB
testcase_08 AC 36 ms
8,816 KB
testcase_09 AC 18 ms
8,680 KB
testcase_10 AC 67 ms
8,968 KB
testcase_11 AC 12 ms
8,692 KB
testcase_12 AC 31 ms
8,868 KB
testcase_13 AC 73 ms
8,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:30:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%d%d%d",&X[i],&Y[i],&H[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%d%d%d%d%d",&x,&y,&w,&h,&d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ln <<endl
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,K;
int X[100000],Y[100000],H[100000];

int sum[1010][1010];

signed main(){
    scanf("%d%d",&N,&K);
    rep(i,N){
        scanf("%d%d%d",&X[i],&Y[i],&H[i]);
        X[i]+=500;Y[i]+=500;
    }

    rep(i,K){
        int x,y,w,h,d;
        scanf("%d%d%d%d%d",&x,&y,&w,&h,&d);
        x+=500;y+=500;w++;h++;chmin(w,1001-x);chmin(h,1001-y);
        sum[x][y]+=d;
        sum[x+w][y]-=d;
        sum[x][y+h]-=d;
        sum[x+w][y+h]+=d;
    }

    rep(i,1001)reps(j,1,1001)sum[i][j]+=sum[i][j-1];
    reps(i,1,1001)rep(j,1001)sum[i][j]+=sum[i-1][j];

    int ans=0;
    rep(i,N)ans+=max(0,H[i]-sum[X[i]][Y[i]]);
    printf("%d\n",ans);
    return 0;
}
0